Commit 4c9ec549 by 王文龙

[add]添加网络监听与推送配置

parent 75ab9224
......@@ -94,7 +94,7 @@ dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation("com.offcn.live:titleview:1.1.0-s1")
implementation("com.offcn.live:imsdk-kit:1.0.0.28")
implementation("com.offcn.live:imsdk-kit:1.0.0.30")
// DB
implementation 'org.greenrobot:greendao:3.2.2'
......
......@@ -116,10 +116,11 @@
android:configChanges="keyboardHidden|screenSize|orientation"
android:excludeFromRecents="true"
android:screenOrientation="portrait"
android:taskAffinity="com.offcn.im.demo.push.activity.PushTranslateActivity"
android:taskAffinity="com.offcn.imclient.ui.PushTranslateActivity"
android:theme="@style/Activity.Translucent">
<intent-filter>
<action android:name="com.offcn.live.im.push" />
<!--注意此处为 包名.push,不可随意修改为其它,否则推送通知栏点击无效-->
<action android:name="${applicationId}.push" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
......
package com.offcn.imclient.ui;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.android.volley.Request;
......@@ -26,6 +29,7 @@ import com.offcn.imclient.view.AnimatedExpandableListView;
import com.offcn.live.im.OIMSDK;
import com.offcn.live.im.bean.OIMSendTypeEnum;
import com.offcn.live.im.util.ZGLLogUtils;
import com.offcn.live.im.util.ZGLNetworkChangeReceiver;
import com.offcn.live.im.util.ZGLParseUtils;
import org.json.JSONObject;
......@@ -42,6 +46,11 @@ import java.util.List;
public class ChatListFragmentWrapper extends BaseFragment {
private static final String TAG = ChatListFragmentWrapper.class.getSimpleName();
LinearLayout mNoNetView;
private ZGLNetworkChangeReceiver mNetworkChangeReceiver;
@Override
protected int getContentViewId() {
return R.layout.fragment_chat_list_wrapper;
......@@ -49,6 +58,8 @@ public class ChatListFragmentWrapper extends BaseFragment {
@Override
protected void init(View view) {
mNoNetView = view.findViewById(R.id.container_nonet);
view.findViewById(R.id.search).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -58,10 +69,45 @@ public class ChatListFragmentWrapper extends BaseFragment {
}
}
});
initNet();
}
@Override
protected boolean setLoadAlways() {
return false;
}
@Override
public void onDestroy() {
super.onDestroy();
try {
if (mNetworkChangeReceiver != null) {
getActivity().unregisterReceiver(mNetworkChangeReceiver);
}
} catch (Exception e) {
}
}
private void initNet() {
mNetworkChangeReceiver = new ZGLNetworkChangeReceiver();
final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
getActivity().registerReceiver(mNetworkChangeReceiver, intentFilter);
mNetworkChangeReceiver.setOnNetChangeListener(new ZGLNetworkChangeReceiver.OnNetChangeListener() {
@Override
public void onConnected(boolean isWifi) {
ZGLLogUtils.e(TAG, "onConnected");
mNoNetView.setVisibility(View.GONE);
}
@Override
public void onDisconnected() {
mNoNetView.setVisibility(View.VISIBLE);
}
});
}
}
......@@ -30,6 +30,7 @@ import com.offcn.live.im.bean.OIMCode;
import com.offcn.live.im.bean.OIMMsg;
import com.offcn.live.im.util.ZGLCommonUtils;
import com.offcn.live.im.util.ZGLLogUtils;
import com.offcn.live.im.util.ZGLNetworkChangeReceiver;
import com.offcn.live.imkit.ui.ChatListFragment;
import com.offcn.live.imkit.util.KitConstants;
import com.offcn.live.imkit.view.ScrollEnabledViewPager;
......@@ -58,6 +59,7 @@ public class MainActivity extends BaseActivity {
private UserBean mUserBean;
@Override
protected int getContentViewLayoutId() {
return R.layout.activity_main;
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:gravity="center"
android:orientation="vertical"
android:background="@android:color/white"
android:paddingTop="@dimen/main_padding_top">
<RelativeLayout
......@@ -28,12 +29,46 @@
android:textSize="15sp" />
</RelativeLayout>
<fragment
android:name="com.offcn.live.imkit.ui.ChatListFragment"
android:id="@+id/chat_list_fragment"
android:layout_marginTop="15dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_nonet"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#fdedee"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="15dp"
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_nonet" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:singleLine="true"
android:text="当前网络不可用,请检查网络设置"
android:textColor="@color/color_333333"
android:textSize="12sp" />
</LinearLayout>
<fragment
android:id="@+id/chat_list_fragment"
android:name="com.offcn.live.imkit.ui.ChatListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
......@@ -2,11 +2,11 @@
<string name="app_name">在线课堂教师版</string>
<string name="push_mi_appid">2882303761518588294</string>
<string name="push_mi_appkey">5761858881294</string>
<string name="push_vivo_appid">104300660</string>
<string name="push_vivo_appkey">5920cbae23f22a915ecabf26554b644e</string>
<string name="push_oppo_appkey">aa5d4f8306b04b7c820019b906e2ce92</string>
<string name="push_oppo_appsecret">365b1426c0a14519b3f96092f0a729a9</string>
<string name="push_mi_appid">2882303761518931116</string>
<string name="push_mi_appkey">5231893188116</string>
<string name="push_vivo_appid">105430534</string>
<string name="push_vivo_appkey">d2b91a4841e49704211a25bde2dc9e11</string>
<string name="push_oppo_appkey">1115a09757a147d3a25433e0404b9055</string>
<string name="push_oppo_appsecret">239dd9255c5349bab1bd526301e07bae</string>
<string name="search">搜索姓名或者手机号</string>
</resources>
\ No newline at end of file
------------小米----------
包名:
com.offcn.imteacher
AppID:
2882303761518931116
AppKey:
5231893188116
AppSecret:
YxfHTk1OHPmctQzgRDZ+Yg==
----------VIVO----------------
应用包名:com.offcn.imteacher
AppID:105430534
AppKey:d2b91a4841e49704211a25bde2dc9e11
AppSecret:9ae21754-7e4a-42e2-8546-20b249d60743
----------OPPO---------------
appid: 30441883
appkey:1115a09757a147d3a25433e0404b9055(勿外泄)
appsecret:239dd9255c5349bab1bd526301e07bae(勿外泄)
appserversecret:b36e458a2e7a46188058a61bdbb9a633(勿外泄)
\ No newline at end of file
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