正在显示
138 个修改的文件
包含
2815 行增加
和
2030 行删除
| @@ -16,7 +16,10 @@ android { | @@ -16,7 +16,10 @@ android { | ||
| 16 | } | 16 | } |
| 17 | buildTypes { | 17 | buildTypes { |
| 18 | release { | 18 | release { |
| 19 | + //是否混淆 | ||
| 19 | minifyEnabled false | 20 | minifyEnabled false |
| 21 | + zipAlignEnabled true | ||
| 22 | +// shrinkResources true//去除无用的resource文件,第一次使用 | ||
| 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 21 | } | 24 | } |
| 22 | } | 25 | } |
| @@ -32,7 +35,6 @@ dependencies { | @@ -32,7 +35,6 @@ dependencies { | ||
| 32 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | 35 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { |
| 33 | exclude group: 'com.android.support', module: 'support-annotations' | 36 | exclude group: 'com.android.support', module: 'support-annotations' |
| 34 | }) | 37 | }) |
| 35 | - compile project(':xdy') | ||
| 36 | compile files('libs/pldroid-player-1.5.1.jar') | 38 | compile files('libs/pldroid-player-1.5.1.jar') |
| 37 | compile 'com.android.support:appcompat-v7:25.3.1' | 39 | compile 'com.android.support:appcompat-v7:25.3.1' |
| 38 | compile 'com.jakewharton:butterknife:8.5.1' | 40 | compile 'com.jakewharton:butterknife:8.5.1' |
| @@ -43,15 +45,16 @@ dependencies { | @@ -43,15 +45,16 @@ dependencies { | ||
| 43 | compile 'org.kymjs.kjframe:kjframe:2.6' | 45 | compile 'org.kymjs.kjframe:kjframe:2.6' |
| 44 | compile 'io.reactivex:rxjava:1.0.9' | 46 | compile 'io.reactivex:rxjava:1.0.9' |
| 45 | compile 'io.reactivex:rxandroid:0.24.0' | 47 | compile 'io.reactivex:rxandroid:0.24.0' |
| 46 | - compile 'com.squareup.retrofit:retrofit:1.9.0' | 48 | +// compile 'com.squareup.retrofit:retrofit:1.9.0' |
| 47 | compile 'com.nineoldandroids:library:2.4.0' | 49 | compile 'com.nineoldandroids:library:2.4.0' |
| 48 | compile 'me.yokeyword:fragmentation:0.10.3' | 50 | compile 'me.yokeyword:fragmentation:0.10.3' |
| 49 | compile 'com.qiniu:happy-dns:0.2.+' | 51 | compile 'com.qiniu:happy-dns:0.2.+' |
| 50 | - compile 'com.android.support:support-v4:25.3.1' | 52 | +// compile 'com.android.support:support-v4:25.3.1' |
| 51 | testCompile 'junit:junit:4.12' | 53 | testCompile 'junit:junit:4.12' |
| 52 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' | 54 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' |
| 53 | compile 'com.qiniu:happy-dns:0.2.+' | 55 | compile 'com.qiniu:happy-dns:0.2.+' |
| 54 | compile 'org.greenrobot:eventbus:3.0.0' | 56 | compile 'org.greenrobot:eventbus:3.0.0' |
| 55 | compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' | 57 | compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' |
| 56 | compile project(':iOS_Dialog_Library') | 58 | compile project(':iOS_Dialog_Library') |
| 59 | + compile project(':xdy') | ||
| 57 | } | 60 | } |
| @@ -15,3 +15,10 @@ | @@ -15,3 +15,10 @@ | ||
| 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { | 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { |
| 16 | # public *; | 16 | # public *; |
| 17 | #} | 17 | #} |
| 18 | + | ||
| 19 | +-keep class com.eventhandle.**{*;} | ||
| 20 | +-keep class com.ntjbase.**{*;} | ||
| 21 | +-keep class com.videoengine.**{*;} | ||
| 22 | +-keep class com.voiceengine.**{*;} | ||
| 23 | + | ||
| 24 | +-keep class com.mang.xdy.**{*;} |
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | - package="com.mang.xdy.demo"> | 3 | + package="com.mang.xuedianyun.android"> |
| 4 | <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> | 4 | <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> |
| 5 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 5 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
| 6 | <uses-permission android:name="android.permission.INTERNET" /> | 6 | <uses-permission android:name="android.permission.INTERNET" /> |
| @@ -36,13 +36,13 @@ | @@ -36,13 +36,13 @@ | ||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | <application | 38 | <application |
| 39 | - android:name=".application.XdyApplicaiton" | 39 | + android:name="com.mang.xuedianyun.android.application.XdyApplicaiton" |
| 40 | android:allowBackup="true" | 40 | android:allowBackup="true" |
| 41 | android:icon="@mipmap/logo" | 41 | android:icon="@mipmap/logo" |
| 42 | android:label="@string/app_name" | 42 | android:label="@string/app_name" |
| 43 | android:supportsRtl="true" | 43 | android:supportsRtl="true" |
| 44 | android:theme="@style/AppTheme"> | 44 | android:theme="@style/AppTheme"> |
| 45 | - <activity android:name=".MainActivity" | 45 | + <activity android:name="com.mang.xuedianyun.android.MainActivity" |
| 46 | android:windowSoftInputMode="adjustPan|stateHidden" | 46 | android:windowSoftInputMode="adjustPan|stateHidden" |
| 47 | android:screenOrientation="portrait"> | 47 | android:screenOrientation="portrait"> |
| 48 | <intent-filter> | 48 | <intent-filter> |
| @@ -51,10 +51,9 @@ | @@ -51,10 +51,9 @@ | ||
| 51 | <category android:name="android.intent.category.LAUNCHER" /> | 51 | <category android:name="android.intent.category.LAUNCHER" /> |
| 52 | </intent-filter> | 52 | </intent-filter> |
| 53 | </activity> | 53 | </activity> |
| 54 | - <activity android:name=".activity.VideoPlayActivity" | 54 | + <activity android:name="com.mang.xuedianyun.android.activity.VideoPlayActivity" |
| 55 | android:configChanges="keyboardHidden|orientation|screenSize" | 55 | android:configChanges="keyboardHidden|orientation|screenSize" |
| 56 | android:screenOrientation="portrait" | 56 | android:screenOrientation="portrait" |
| 57 | - android:windowSoftInputMode="adjustPan|stateHidden" | ||
| 58 | > | 57 | > |
| 59 | </activity> | 58 | </activity> |
| 60 | </application> | 59 | </application> |
| 1 | -package com.mang.xdy.demo; | ||
| 2 | - | ||
| 3 | -import android.content.Context; | ||
| 4 | -import android.content.Intent; | ||
| 5 | -import android.content.res.Configuration; | ||
| 6 | -import android.os.Bundle; | ||
| 7 | -import android.support.v7.app.AppCompatActivity; | ||
| 8 | -import android.text.TextUtils; | ||
| 9 | -import android.view.View; | ||
| 10 | -import android.widget.Button; | ||
| 11 | -import android.widget.EditText; | ||
| 12 | -import android.widget.RelativeLayout; | ||
| 13 | - | ||
| 14 | -import com.google.gson.Gson; | ||
| 15 | - | ||
| 16 | -import com.mang.xdy.demo.activity.VideoPlayActivity; | ||
| 17 | -import com.mang.xdy.demo.bean.JoinClassBean; | ||
| 18 | -import com.mang.xdy.demo.utils.ToastUtil; | ||
| 19 | - | ||
| 20 | -import java.util.ArrayList; | ||
| 21 | - | ||
| 22 | -import butterknife.BindView; | ||
| 23 | -import butterknife.ButterKnife; | ||
| 24 | -import butterknife.OnClick; | ||
| 25 | - | ||
| 26 | -public class MainActivity extends AppCompatActivity { | ||
| 27 | - | ||
| 28 | - @BindView(R.id.edt_home_classId) | ||
| 29 | - EditText edtHomeClassId; | ||
| 30 | - @BindView(R.id.edt_home_role) | ||
| 31 | - EditText edtHomeRole; | ||
| 32 | - @BindView(R.id.edt_home_serviceIp) | ||
| 33 | - EditText edtHomeServiceIp; | ||
| 34 | - @BindView(R.id.edt_home_userId) | ||
| 35 | - EditText edtHomeUserId; | ||
| 36 | - @BindView(R.id.btn_home_enter_class) | ||
| 37 | - Button btnHomeEnterClass; | ||
| 38 | - @BindView(R.id.btn_home_enter_publisher) | ||
| 39 | - Button btn_home_enter_publisher; | ||
| 40 | - @BindView(R.id.rl_home_close) | ||
| 41 | - RelativeLayout rl_home_close; | ||
| 42 | - /*一进来就要初始化,让后再调 加入课堂*/ | ||
| 43 | - @Override | ||
| 44 | - protected void onCreate(Bundle savedInstanceState) { | ||
| 45 | - super.onCreate(savedInstanceState); | ||
| 46 | - setContentView(R.layout.activity_main); | ||
| 47 | - ButterKnife.bind(this); | ||
| 48 | - rl_home_close.setOnClickListener(new View.OnClickListener() { | ||
| 49 | - @Override | ||
| 50 | - public void onClick(View v) { | ||
| 51 | - finish(); | ||
| 52 | - } | ||
| 53 | - }); | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - @OnClick({R.id.btn_home_enter_class,R.id.btn_home_enter_publisher}) | ||
| 57 | - public void onViewClicked(View view) { | ||
| 58 | - if(TextUtils.isEmpty(joinClass())){ | ||
| 59 | - return; | ||
| 60 | - } | ||
| 61 | - ArrayList<String> arrayList=new ArrayList<>(); | ||
| 62 | - switch (view.getId()){ | ||
| 63 | - | ||
| 64 | - case R.id.btn_home_enter_class: | ||
| 65 | - Intent intent=new Intent(MainActivity.this, VideoPlayActivity.class); | ||
| 66 | - arrayList.clear(); | ||
| 67 | - arrayList.add(joinClass()); | ||
| 68 | - arrayList.add("normal"); | ||
| 69 | - intent.putStringArrayListExtra("init",arrayList); | ||
| 70 | - startActivity(intent); | ||
| 71 | - break; | ||
| 72 | - case R.id.btn_home_enter_publisher: | ||
| 73 | - Intent intents=new Intent(MainActivity.this, VideoPlayActivity.class); | ||
| 74 | - arrayList.clear(); | ||
| 75 | - arrayList.add(joinClass()); | ||
| 76 | - arrayList.add(""); | ||
| 77 | - intents.putStringArrayListExtra("init",arrayList); | ||
| 78 | - startActivity(intents); | ||
| 79 | - break; | ||
| 80 | - | ||
| 81 | - } | ||
| 82 | - } | ||
| 83 | - private String classId=""; | ||
| 84 | - private String userRole=""; | ||
| 85 | - private String serviceIp=""; | ||
| 86 | - private String userId=""; | ||
| 87 | - public boolean getLoginInfo(){ | ||
| 88 | - classId=edtHomeClassId.getText().toString(); | ||
| 89 | - userRole=edtHomeRole.getText().toString(); | ||
| 90 | - serviceIp=edtHomeServiceIp.getText().toString(); | ||
| 91 | - userId=edtHomeUserId.getText().toString(); | ||
| 92 | - if(TextUtils.isEmpty(classId)){ | ||
| 93 | - ToastUtil.showToast(getResources().getString(R.string.main_login_error_classId),this); | ||
| 94 | - return false; | ||
| 95 | - } | ||
| 96 | - if(TextUtils.isEmpty(serviceIp)){ | ||
| 97 | - ToastUtil.showToast(getResources().getString(R.string.main_login_error_portal),this); | ||
| 98 | - return false; | ||
| 99 | - } | ||
| 100 | - if(TextUtils.isEmpty(userRole)){ | ||
| 101 | - ToastUtil.showToast(getResources().getString(R.string.main_login_error_role),this); | ||
| 102 | - return false; | ||
| 103 | - } | ||
| 104 | - if(TextUtils.isEmpty(userId)){ | ||
| 105 | - ToastUtil.showToast(getResources().getString(R.string.main_login_error_userId),this); | ||
| 106 | - return false; | ||
| 107 | - } | ||
| 108 | - return true; | ||
| 109 | - } | ||
| 110 | - public String joinClass(){ | ||
| 111 | - if(getLoginInfo()) { | ||
| 112 | - JoinClassBean joinClassBean = new JoinClassBean(); | ||
| 113 | - joinClassBean.setClassId(Integer.parseInt(classId)); | ||
| 114 | - joinClassBean.setUserRole(userRole); | ||
| 115 | - joinClassBean.setPortal(serviceIp); | ||
| 116 | - joinClassBean.setUserId(Integer.parseInt(userId)); | ||
| 117 | - joinClassBean.setUserName(""); | ||
| 118 | - String joinclass = new Gson().toJson(joinClassBean); | ||
| 119 | -// XdyLogUtil.e("init 初始化", joinclass); | ||
| 120 | - return joinclass; | ||
| 121 | - }else{ | ||
| 122 | - return ""; | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - | ||
| 128 | - | ||
| 129 | -} | 1 | +package com.mang.xuedianyun.android; |
| 2 | + | ||
| 3 | +import android.content.Intent; | ||
| 4 | +import android.os.Bundle; | ||
| 5 | +import android.support.v7.app.AppCompatActivity; | ||
| 6 | +import android.text.TextUtils; | ||
| 7 | +import android.view.View; | ||
| 8 | +import android.widget.Button; | ||
| 9 | +import android.widget.EditText; | ||
| 10 | +import android.widget.RelativeLayout; | ||
| 11 | + | ||
| 12 | +import com.google.gson.Gson; | ||
| 13 | + | ||
| 14 | +import com.mang.xuedianyun.android.activity.VideoPlayActivity; | ||
| 15 | +import com.mang.xuedianyun.android.bean.JoinClassBean; | ||
| 16 | +import com.mang.xuedianyun.android.utils.ToastUtil; | ||
| 17 | + | ||
| 18 | +import java.util.ArrayList; | ||
| 19 | + | ||
| 20 | +import butterknife.BindView; | ||
| 21 | +import butterknife.ButterKnife; | ||
| 22 | +import butterknife.OnClick; | ||
| 23 | + | ||
| 24 | +public class MainActivity extends AppCompatActivity { | ||
| 25 | + | ||
| 26 | + @BindView(R.id.edt_home_classId) | ||
| 27 | + EditText edtHomeClassId; | ||
| 28 | + @BindView(R.id.edt_home_role) | ||
| 29 | + EditText edtHomeRole; | ||
| 30 | + @BindView(R.id.edt_home_serviceIp) | ||
| 31 | + EditText edtHomeServiceIp; | ||
| 32 | + @BindView(R.id.edt_home_userId) | ||
| 33 | + EditText edtHomeUserId; | ||
| 34 | + @BindView(R.id.btn_home_enter_class) | ||
| 35 | + Button btnHomeEnterClass; | ||
| 36 | + @BindView(R.id.btn_home_enter_publisher) | ||
| 37 | + Button btn_home_enter_publisher; | ||
| 38 | + @BindView(R.id.rl_home_close) | ||
| 39 | + RelativeLayout rl_home_close; | ||
| 40 | + /*一进来就要初始化,让后再调 加入课堂*/ | ||
| 41 | + @Override | ||
| 42 | + protected void onCreate(Bundle savedInstanceState) { | ||
| 43 | + super.onCreate(savedInstanceState); | ||
| 44 | + setContentView(R.layout.activity_main); | ||
| 45 | + ButterKnife.bind(this); | ||
| 46 | + rl_home_close.setOnClickListener(new View.OnClickListener() { | ||
| 47 | + @Override | ||
| 48 | + public void onClick(View v) { | ||
| 49 | + finish(); | ||
| 50 | + } | ||
| 51 | + }); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @OnClick({R.id.btn_home_enter_class,R.id.btn_home_enter_publisher}) | ||
| 55 | + public void onViewClicked(View view) { | ||
| 56 | + if(TextUtils.isEmpty(joinClass())){ | ||
| 57 | + return; | ||
| 58 | + } | ||
| 59 | + ArrayList<String> arrayList=new ArrayList<>(); | ||
| 60 | + switch (view.getId()){ | ||
| 61 | + | ||
| 62 | + case R.id.btn_home_enter_class: | ||
| 63 | + Intent intent=new Intent(MainActivity.this, VideoPlayActivity.class); | ||
| 64 | + arrayList.clear(); | ||
| 65 | + arrayList.add(joinClass()); | ||
| 66 | + arrayList.add("normal"); | ||
| 67 | + intent.putStringArrayListExtra("init",arrayList); | ||
| 68 | + startActivity(intent); | ||
| 69 | + break; | ||
| 70 | + case R.id.btn_home_enter_publisher: | ||
| 71 | + Intent intents=new Intent(MainActivity.this, VideoPlayActivity.class); | ||
| 72 | + arrayList.clear(); | ||
| 73 | + arrayList.add(joinClass()); | ||
| 74 | + arrayList.add(""); | ||
| 75 | + intents.putStringArrayListExtra("init",arrayList); | ||
| 76 | + startActivity(intents); | ||
| 77 | + break; | ||
| 78 | + | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + private String classId=""; | ||
| 82 | + private String userRole=""; | ||
| 83 | + private String serviceIp=""; | ||
| 84 | + private String userId=""; | ||
| 85 | + public boolean getLoginInfo(){ | ||
| 86 | + classId=edtHomeClassId.getText().toString(); | ||
| 87 | + userRole=edtHomeRole.getText().toString(); | ||
| 88 | + serviceIp=edtHomeServiceIp.getText().toString(); | ||
| 89 | + userId=edtHomeUserId.getText().toString(); | ||
| 90 | + if(TextUtils.isEmpty(classId)){ | ||
| 91 | + ToastUtil.showToast(getResources().getString(R.string.main_login_error_classId),this); | ||
| 92 | + return false; | ||
| 93 | + } | ||
| 94 | + if(TextUtils.isEmpty(serviceIp)){ | ||
| 95 | + ToastUtil.showToast(getResources().getString(R.string.main_login_error_portal),this); | ||
| 96 | + return false; | ||
| 97 | + } | ||
| 98 | + if(TextUtils.isEmpty(userRole)){ | ||
| 99 | + ToastUtil.showToast(getResources().getString(R.string.main_login_error_role),this); | ||
| 100 | + return false; | ||
| 101 | + } | ||
| 102 | + if(TextUtils.isEmpty(userId)){ | ||
| 103 | + ToastUtil.showToast(getResources().getString(R.string.main_login_error_userId),this); | ||
| 104 | + return false; | ||
| 105 | + } | ||
| 106 | + return true; | ||
| 107 | + } | ||
| 108 | + public String joinClass(){ | ||
| 109 | + if(getLoginInfo()) { | ||
| 110 | + JoinClassBean joinClassBean = new JoinClassBean(); | ||
| 111 | + joinClassBean.setClassId(Integer.parseInt(classId)); | ||
| 112 | + joinClassBean.setUserRole(userRole); | ||
| 113 | + joinClassBean.setPortal(serviceIp); | ||
| 114 | + joinClassBean.setUserId(Integer.parseInt(userId)); | ||
| 115 | + joinClassBean.setUserName(""); | ||
| 116 | + String joinclass = new Gson().toJson(joinClassBean); | ||
| 117 | +// XdyLogUtil.e("init 初始化", joinclass); | ||
| 118 | + return joinclass; | ||
| 119 | + }else{ | ||
| 120 | + return ""; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + | ||
| 126 | + | ||
| 127 | +} |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.adapter; | 16 | +package com.mang.xuedianyun.android.adapter; |
| 17 | 17 | ||
| 18 | import android.content.Context; | 18 | import android.content.Context; |
| 19 | import android.text.TextUtils; | 19 | import android.text.TextUtils; |
| @@ -28,12 +28,12 @@ import android.widget.TextView; | @@ -28,12 +28,12 @@ import android.widget.TextView; | ||
| 28 | 28 | ||
| 29 | import com.mang.xdy.common.Constants; | 29 | import com.mang.xdy.common.Constants; |
| 30 | import com.mang.xdy.utils.SPUtil; | 30 | import com.mang.xdy.utils.SPUtil; |
| 31 | -import com.mang.xdy.demo.R; | ||
| 32 | -import com.mang.xdy.demo.bean.JoinClassSuccessEntity; | ||
| 33 | -import com.mang.xdy.demo.bean.Message; | ||
| 34 | -import com.mang.xdy.demo.fragment.ChatFragment; | ||
| 35 | -import com.mang.xdy.demo.utils.JsonUtil; | ||
| 36 | -import com.mang.xdy.demo.widget.chat.UrlUtils; | 31 | +import com.mang.xuedianyun.android.R; |
| 32 | +import com.mang.xuedianyun.android.bean.JoinClassSuccessEntity; | ||
| 33 | +import com.mang.xuedianyun.android.bean.Message; | ||
| 34 | +import com.mang.xuedianyun.android.fragment.ChatFragment; | ||
| 35 | +import com.mang.xuedianyun.android.utils.JsonUtil; | ||
| 36 | +import com.mang.xuedianyun.android.widget.chat.UrlUtils; | ||
| 37 | 37 | ||
| 38 | import org.kymjs.kjframe.KJBitmap; | 38 | import org.kymjs.kjframe.KJBitmap; |
| 39 | 39 |
| @@ -13,14 +13,14 @@ | @@ -13,14 +13,14 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.adapter; | 16 | +package com.mang.xuedianyun.android.adapter; |
| 17 | 17 | ||
| 18 | import android.widget.AbsListView; | 18 | import android.widget.AbsListView; |
| 19 | import android.widget.ImageView; | 19 | import android.widget.ImageView; |
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | -import com.mang.xdy.demo.R; | ||
| 23 | -import com.mang.xdy.demo.bean.Faceicon; | 22 | +import com.mang.xuedianyun.android.R; |
| 23 | +import com.mang.xuedianyun.android.bean.Faceicon; | ||
| 24 | 24 | ||
| 25 | import org.kymjs.kjframe.KJBitmap; | 25 | import org.kymjs.kjframe.KJBitmap; |
| 26 | import org.kymjs.kjframe.widget.AdapterHolder; | 26 | import org.kymjs.kjframe.widget.AdapterHolder; |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.adapter; | 16 | +package com.mang.xuedianyun.android.adapter; |
| 17 | 17 | ||
| 18 | import android.graphics.Bitmap; | 18 | import android.graphics.Bitmap; |
| 19 | import android.os.Bundle; | 19 | import android.os.Bundle; |
| @@ -23,13 +23,13 @@ import android.support.v4.app.FragmentStatePagerAdapter; | @@ -23,13 +23,13 @@ import android.support.v4.app.FragmentStatePagerAdapter; | ||
| 23 | import android.widget.ImageView; | 23 | import android.widget.ImageView; |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | -import com.mang.xdy.demo.R; | ||
| 27 | -import com.mang.xdy.demo.widget.chat.ChatFunctionFragment; | ||
| 28 | -import com.mang.xdy.demo.widget.chat.FacePageFragment; | ||
| 29 | -import com.mang.xdy.demo.widget.chat.KJChatKeyboard; | ||
| 30 | -import com.mang.xdy.demo.widget.chat.OnOperationListener; | ||
| 31 | -import com.mang.xdy.demo.widget.chat.PagerSlidingTabStrip; | ||
| 32 | -import com.mang.xdy.demo.widget.emoji.EmojiPageFragment; | 26 | +import com.mang.xuedianyun.android.R; |
| 27 | +import com.mang.xuedianyun.android.widget.chat.ChatFunctionFragment; | ||
| 28 | +import com.mang.xuedianyun.android.widget.chat.FacePageFragment; | ||
| 29 | +import com.mang.xuedianyun.android.widget.chat.KJChatKeyboard; | ||
| 30 | +import com.mang.xuedianyun.android.widget.chat.OnOperationListener; | ||
| 31 | +import com.mang.xuedianyun.android.widget.chat.PagerSlidingTabStrip; | ||
| 32 | +import com.mang.xuedianyun.android.widget.emoji.EmojiPageFragment; | ||
| 33 | 33 | ||
| 34 | import org.kymjs.kjframe.bitmap.BitmapCreate; | 34 | import org.kymjs.kjframe.bitmap.BitmapCreate; |
| 35 | 35 |
| 1 | -package com.mang.xdy.demo.adapter; | 1 | +package com.mang.xuedianyun.android.adapter; |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | * Created by huang on 2017/4/9. | 4 | * Created by huang on 2017/4/9. |
| @@ -9,9 +9,8 @@ import android.support.v4.app.Fragment; | @@ -9,9 +9,8 @@ import android.support.v4.app.Fragment; | ||
| 9 | import android.support.v4.app.FragmentManager; | 9 | import android.support.v4.app.FragmentManager; |
| 10 | import android.support.v4.app.FragmentPagerAdapter; | 10 | import android.support.v4.app.FragmentPagerAdapter; |
| 11 | 11 | ||
| 12 | -import com.mang.xdy.demo.fragment.ChatFragment; | ||
| 13 | -import com.mang.xdy.demo.fragment.DocFragment; | ||
| 14 | -import com.mang.xdy.demo.fragment.PageFragment; | 12 | +import com.mang.xuedianyun.android.fragment.ChatFragment; |
| 13 | +import com.mang.xuedianyun.android.fragment.DocFragment; | ||
| 15 | 14 | ||
| 16 | import java.util.ArrayList; | 15 | import java.util.ArrayList; |
| 17 | import java.util.List; | 16 | import java.util.List; |
| 1 | -package com.mang.xdy.demo.application; | 1 | +package com.mang.xuedianyun.android.application; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.app.Application; | 4 | import android.app.Application; |
| 5 | import android.content.Context; | 5 | import android.content.Context; |
| 6 | 6 | ||
| 7 | import com.mang.xdy.core.XdySdk; | 7 | import com.mang.xdy.core.XdySdk; |
| 8 | -import com.mang.xdy.demo.utils.ResUtil; | 8 | +import com.mang.xuedianyun.android.utils.ResUtil; |
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * Created by abao on 2017/3/30. | 11 | * Created by abao on 2017/3/30. |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.bean; | 16 | +package com.mang.xuedianyun.android.bean; |
| 17 | 17 | ||
| 18 | import java.io.Serializable; | 18 | import java.io.Serializable; |
| 19 | 19 |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.bean; | 16 | +package com.mang.xuedianyun.android.bean; |
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| 19 | * 聊天消息javabean | 19 | * 聊天消息javabean |
| 1 | -package com.mang.xdy.demo.dialog; | 1 | +package com.mang.xuedianyun.android.dialog; |
| 2 | 2 | ||
| 3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| @@ -15,7 +15,7 @@ import android.view.Window; | @@ -15,7 +15,7 @@ import android.view.Window; | ||
| 15 | import android.view.WindowManager.LayoutParams; | 15 | import android.view.WindowManager.LayoutParams; |
| 16 | import android.widget.LinearLayout; | 16 | import android.widget.LinearLayout; |
| 17 | 17 | ||
| 18 | -import com.mang.xdy.demo.utils.DisplayUtil; | 18 | +import com.mang.xuedianyun.android.utils.DisplayUtil; |
| 19 | import com.nineoldandroids.animation.Animator; | 19 | import com.nineoldandroids.animation.Animator; |
| 20 | 20 | ||
| 21 | import java.lang.ref.WeakReference; | 21 | import java.lang.ref.WeakReference; |
| 1 | -package com.mang.xdy.demo.dialog; | 1 | +package com.mang.xuedianyun.android.dialog; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
| @@ -9,7 +9,7 @@ import android.view.View; | @@ -9,7 +9,7 @@ import android.view.View; | ||
| 9 | import android.widget.LinearLayout; | 9 | import android.widget.LinearLayout; |
| 10 | import android.widget.TextView; | 10 | import android.widget.TextView; |
| 11 | 11 | ||
| 12 | -import com.mang.xdy.demo.R; | 12 | +import com.mang.xuedianyun.android.R; |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | public class NormalDialog extends BaseDialog { | 15 | public class NormalDialog extends BaseDialog { |
| 1 | -package com.mang.xdy.demo.dialog; | 1 | +package com.mang.xuedianyun.android.dialog; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.graphics.Color; | 4 | import android.graphics.Color; |
| @@ -9,7 +9,7 @@ import android.view.View; | @@ -9,7 +9,7 @@ import android.view.View; | ||
| 9 | import android.widget.LinearLayout; | 9 | import android.widget.LinearLayout; |
| 10 | import android.widget.TextView; | 10 | import android.widget.TextView; |
| 11 | 11 | ||
| 12 | -import com.mang.xdy.demo.R; | 12 | +import com.mang.xuedianyun.android.R; |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| 1 | -package com.mang.xdy.demo.fragment; | 1 | +package com.mang.xuedianyun.android.fragment; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| @@ -18,17 +18,17 @@ import com.google.gson.Gson; | @@ -18,17 +18,17 @@ import com.google.gson.Gson; | ||
| 18 | import com.mang.xdy.common.Constants; | 18 | import com.mang.xdy.common.Constants; |
| 19 | import com.mang.xdy.utils.SPUtil; | 19 | import com.mang.xdy.utils.SPUtil; |
| 20 | import com.mang.xdy.core.XdySdk; | 20 | import com.mang.xdy.core.XdySdk; |
| 21 | -import com.mang.xdy.demo.R; | ||
| 22 | -import com.mang.xdy.demo.adapter.ChatAdapter; | ||
| 23 | -import com.mang.xdy.demo.bean.ChatMsgEntity; | ||
| 24 | -import com.mang.xdy.demo.bean.Faceicon; | ||
| 25 | -import com.mang.xdy.demo.bean.JoinClassSuccessEntity; | ||
| 26 | -import com.mang.xdy.demo.bean.Message; | ||
| 27 | -import com.mang.xdy.demo.bean.SendChatMsgEntity; | ||
| 28 | -import com.mang.xdy.demo.utils.JsonUtil; | ||
| 29 | -import com.mang.xdy.demo.widget.chat.KJChatKeyboard; | ||
| 30 | -import com.mang.xdy.demo.widget.chat.OnOperationListener; | ||
| 31 | -import com.mang.xdy.demo.widget.emoji.DisplayRules; | 21 | +import com.mang.xuedianyun.android.R; |
| 22 | +import com.mang.xuedianyun.android.adapter.ChatAdapter; | ||
| 23 | +import com.mang.xuedianyun.android.bean.ChatMsgEntity; | ||
| 24 | +import com.mang.xuedianyun.android.bean.Faceicon; | ||
| 25 | +import com.mang.xuedianyun.android.bean.JoinClassSuccessEntity; | ||
| 26 | +import com.mang.xuedianyun.android.bean.Message; | ||
| 27 | +import com.mang.xuedianyun.android.bean.SendChatMsgEntity; | ||
| 28 | +import com.mang.xuedianyun.android.utils.JsonUtil; | ||
| 29 | +import com.mang.xuedianyun.android.widget.chat.KJChatKeyboard; | ||
| 30 | +import com.mang.xuedianyun.android.widget.chat.OnOperationListener; | ||
| 31 | +import com.mang.xuedianyun.android.widget.emoji.DisplayRules; | ||
| 32 | import com.mang.xdy.listener.ObserverListener; | 32 | import com.mang.xdy.listener.ObserverListener; |
| 33 | import com.mang.xdy.utils.XdyLogUtil; | 33 | import com.mang.xdy.utils.XdyLogUtil; |
| 34 | 34 |
| 1 | -package com.mang.xdy.demo.fragment; | 1 | +package com.mang.xuedianyun.android.fragment; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.graphics.Bitmap; | 4 | import android.graphics.Bitmap; |
| @@ -11,21 +11,20 @@ import android.support.v4.app.Fragment; | @@ -11,21 +11,20 @@ import android.support.v4.app.Fragment; | ||
| 11 | import android.text.TextUtils; | 11 | import android.text.TextUtils; |
| 12 | import android.util.DisplayMetrics; | 12 | import android.util.DisplayMetrics; |
| 13 | import android.view.LayoutInflater; | 13 | import android.view.LayoutInflater; |
| 14 | -import android.view.SurfaceView; | ||
| 15 | import android.view.View; | 14 | import android.view.View; |
| 16 | import android.view.ViewGroup; | 15 | import android.view.ViewGroup; |
| 17 | 16 | ||
| 18 | import com.bumptech.glide.Glide; | 17 | import com.bumptech.glide.Glide; |
| 19 | import com.mang.xdy.common.Constants; | 18 | import com.mang.xdy.common.Constants; |
| 20 | import com.mang.xdy.core.XdySdk; | 19 | import com.mang.xdy.core.XdySdk; |
| 21 | -import com.mang.xdy.demo.R; | ||
| 22 | -import com.mang.xdy.demo.base.BaseRunnable; | ||
| 23 | -import com.mang.xdy.demo.bean.DocEntity; | ||
| 24 | -import com.mang.xdy.demo.bean.WhiteboardUpdateEntity; | ||
| 25 | -import com.mang.xdy.demo.bean.WrapDocBitMapEntity; | ||
| 26 | -import com.mang.xdy.demo.utils.JsonUtil; | ||
| 27 | -import com.mang.xdy.demo.utils.ToastUtil; | ||
| 28 | -import com.mang.xdy.demo.widget.CanvasView; | 20 | +import com.mang.xuedianyun.android.R; |
| 21 | +import com.mang.xuedianyun.android.base.BaseRunnable; | ||
| 22 | +import com.mang.xuedianyun.android.bean.DocEntity; | ||
| 23 | +import com.mang.xuedianyun.android.bean.WhiteboardUpdateEntity; | ||
| 24 | +import com.mang.xuedianyun.android.bean.WrapDocBitMapEntity; | ||
| 25 | +import com.mang.xuedianyun.android.utils.JsonUtil; | ||
| 26 | +import com.mang.xuedianyun.android.utils.ToastUtil; | ||
| 27 | +import com.mang.xuedianyun.android.widget.CanvasView; | ||
| 29 | import com.mang.xdy.listener.ObserverListener; | 28 | import com.mang.xdy.listener.ObserverListener; |
| 30 | import com.mang.xdy.utils.XdyLogUtil; | 29 | import com.mang.xdy.utils.XdyLogUtil; |
| 31 | 30 | ||
| @@ -85,7 +84,7 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -85,7 +84,7 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 85 | @Override | 84 | @Override |
| 86 | public void handleMessage(Message msg) { | 85 | public void handleMessage(Message msg) { |
| 87 | super.handleMessage(msg); | 86 | super.handleMessage(msg); |
| 88 | - ToastUtil.showToastshort("图片加载失败",mContext); | 87 | + ToastUtil.showToastshort(getResources().getString(R.string.imge_load_error),mContext); |
| 89 | } | 88 | } |
| 90 | }; | 89 | }; |
| 91 | 90 | ||
| @@ -99,17 +98,15 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -99,17 +98,15 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 99 | 98 | ||
| 100 | 99 | ||
| 101 | public void init(){ | 100 | public void init(){ |
| 102 | - | ||
| 103 | Bundle arguments = getArguments(); | 101 | Bundle arguments = getArguments(); |
| 104 | if(arguments!=null) | 102 | if(arguments!=null) |
| 105 | replay = arguments.getBoolean("replay"); | 103 | replay = arguments.getBoolean("replay"); |
| 106 | DisplayMetrics metric = new DisplayMetrics(); | 104 | DisplayMetrics metric = new DisplayMetrics(); |
| 107 | getWindowWith(metric); | 105 | getWindowWith(metric); |
| 108 | docUrlTransformBitmap(null); | 106 | docUrlTransformBitmap(null); |
| 109 | -// mCanvasView.setZOrderMediaOverlay(false); | ||
| 110 | -// mCanvasView.setZOrderOnTop(false); | ||
| 111 | -//// mCanvasView.getHolder().setFormat(SurfaceView.TRANSPARENT); | ||
| 112 | -// mCanvasView.getHolder().setFormat(SurfaceView.TRANSPARENT); | 107 | + if(replay) { |
| 108 | + mCanvasView.setZOrderMediaOverlay(true); | ||
| 109 | + } | ||
| 113 | } | 110 | } |
| 114 | 111 | ||
| 115 | private void getWindowWith(DisplayMetrics metric) { | 112 | private void getWindowWith(DisplayMetrics metric) { |
| @@ -237,7 +234,7 @@ public class DocFragment extends Fragment implements ObserverListener{ | @@ -237,7 +234,7 @@ public class DocFragment extends Fragment implements ObserverListener{ | ||
| 237 | public void call(WrapDocBitMapEntity resource) { | 234 | public void call(WrapDocBitMapEntity resource) { |
| 238 | 235 | ||
| 239 | if (resource.getBitmap() == null) { | 236 | if (resource.getBitmap() == null) { |
| 240 | - ToastUtil.showToastshort("图片获取失败",mContext); | 237 | + ToastUtil.showToastshort(getResources().getString(R.string.imge_load_error),mContext); |
| 241 | Bitmap bitmap = getEmptyBitmap(); | 238 | Bitmap bitmap = getEmptyBitmap(); |
| 242 | mCanvasView.setBitmap(bitmap, false); | 239 | mCanvasView.setBitmap(bitmap, false); |
| 243 | } else { | 240 | } else { |
| 1 | -package com.mang.xdy.demo.fragment; | 1 | +package com.mang.xuedianyun.android.fragment; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| @@ -9,7 +9,7 @@ import android.view.View; | @@ -9,7 +9,7 @@ import android.view.View; | ||
| 9 | import android.view.ViewGroup; | 9 | import android.view.ViewGroup; |
| 10 | import android.widget.TextView; | 10 | import android.widget.TextView; |
| 11 | 11 | ||
| 12 | -import com.mang.xdy.demo.R; | 12 | +import com.mang.xuedianyun.android.R; |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| 1 | -package com.mang.xdy.demo.fragment; | 1 | +package com.mang.xuedianyun.android.fragment; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| @@ -7,12 +7,13 @@ import android.view.LayoutInflater; | @@ -7,12 +7,13 @@ import android.view.LayoutInflater; | ||
| 7 | import android.view.View; | 7 | import android.view.View; |
| 8 | import android.view.ViewGroup; | 8 | import android.view.ViewGroup; |
| 9 | 9 | ||
| 10 | -import com.mang.xdy.demo.R; | 10 | +import com.mang.xuedianyun.android.R; |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | * A simple {@link Fragment} subclass. | 13 | * A simple {@link Fragment} subclass. |
| 14 | * Use the {@link PublishFragment#newInstance} factory method to | 14 | * Use the {@link PublishFragment#newInstance} factory method to |
| 15 | * create an instance of this fragment. | 15 | * create an instance of this fragment. |
| 16 | + * @deprecated | ||
| 16 | */ | 17 | */ |
| 17 | public class PublishFragment extends Fragment { | 18 | public class PublishFragment extends Fragment { |
| 18 | // TODO: Rename parameter arguments, choose names that match | 19 | // TODO: Rename parameter arguments, choose names that match |
| 1 | -package com.mang.xdy.demo.utils; | ||
| 2 | - | ||
| 3 | -import android.annotation.SuppressLint; | ||
| 4 | -import android.app.Activity; | ||
| 5 | -import android.content.Context; | ||
| 6 | -import android.content.res.Resources; | ||
| 7 | -import android.graphics.Rect; | ||
| 8 | -import android.util.DisplayMetrics; | ||
| 9 | -import android.view.View; | ||
| 10 | -import android.view.Window; | ||
| 11 | -import android.view.WindowManager; | ||
| 12 | - | ||
| 13 | -import java.lang.reflect.Field; | ||
| 14 | -import java.lang.reflect.InvocationTargetException; | ||
| 15 | -import java.lang.reflect.Method; | 1 | +package com.mang.xuedianyun.android.utils; |
| 16 | 2 | ||
| 17 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
| 18 | import android.app.Activity; | 4 | import android.app.Activity; |
| 1 | -package com.mang.xdy.demo.utils; | ||
| 2 | - | ||
| 3 | -import android.content.Context; | ||
| 4 | -import android.content.res.Resources; | ||
| 5 | -import android.support.annotation.StringRes; | ||
| 6 | - | ||
| 7 | -import java.io.BufferedReader; | ||
| 8 | -import java.io.IOException; | ||
| 9 | -import java.io.InputStream; | ||
| 10 | -import java.io.InputStreamReader; | 1 | +package com.mang.xuedianyun.android.utils; |
| 11 | 2 | ||
| 12 | import android.content.Context; | 3 | import android.content.Context; |
| 13 | import android.content.res.Resources; | 4 | import android.content.res.Resources; |
| @@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
| 11 | * See the License for the specific language governing permissions and | 11 | * See the License for the specific language governing permissions and |
| 12 | * limitations under the License. | 12 | * limitations under the License. |
| 13 | */ | 13 | */ |
| 14 | -package com.mang.xdy.demo.utils.cache; | 14 | +package com.mang.xuedianyun.android.utils.cache; |
| 15 | 15 | ||
| 16 | import android.content.Context; | 16 | import android.content.Context; |
| 17 | import android.graphics.Bitmap; | 17 | import android.graphics.Bitmap; |
| 1 | -package com.mang.xdy.demo.widget; | 1 | +package com.mang.xuedianyun.android.widget; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.graphics.Bitmap; | 4 | import android.graphics.Bitmap; |
| @@ -17,13 +17,12 @@ import android.view.SurfaceHolder; | @@ -17,13 +17,12 @@ import android.view.SurfaceHolder; | ||
| 17 | import android.view.SurfaceView; | 17 | import android.view.SurfaceView; |
| 18 | import android.view.View; | 18 | import android.view.View; |
| 19 | 19 | ||
| 20 | -import com.mang.xdy.demo.R; | ||
| 21 | -import com.mang.xdy.demo.bean.AnnotaionEntity; | ||
| 22 | -import com.mang.xdy.demo.bean.PointGroupEntity; | ||
| 23 | -import com.mang.xdy.demo.bean.PointXY; | ||
| 24 | -import com.mang.xdy.demo.utils.DisplayUtil; | ||
| 25 | -import com.mang.xdy.demo.utils.ResUtil; | ||
| 26 | -import com.mang.xdy.utils.XdyLogUtil; | 20 | +import com.mang.xuedianyun.android.R; |
| 21 | +import com.mang.xuedianyun.android.bean.AnnotaionEntity; | ||
| 22 | +import com.mang.xuedianyun.android.bean.PointGroupEntity; | ||
| 23 | +import com.mang.xuedianyun.android.bean.PointXY; | ||
| 24 | +import com.mang.xuedianyun.android.utils.DisplayUtil; | ||
| 25 | +import com.mang.xuedianyun.android.utils.ResUtil; | ||
| 27 | 26 | ||
| 28 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
| 29 | import java.util.Iterator; | 28 | import java.util.Iterator; |
| 1 | +package com.mang.xuedianyun.android.widget.answersheet; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.os.CountDownTimer; | ||
| 5 | +import android.util.AttributeSet; | ||
| 6 | +import android.view.Display; | ||
| 7 | +import android.view.LayoutInflater; | ||
| 8 | +import android.view.View; | ||
| 9 | +import android.widget.CheckBox; | ||
| 10 | +import android.widget.LinearLayout; | ||
| 11 | +import android.widget.RadioButton; | ||
| 12 | +import android.widget.RelativeLayout; | ||
| 13 | +import android.widget.TextView; | ||
| 14 | + | ||
| 15 | +import com.mang.xuedianyun.android.R; | ||
| 16 | +import com.mang.xuedianyun.android.utils.ToastUtil; | ||
| 17 | + | ||
| 18 | +import butterknife.BindView; | ||
| 19 | +import butterknife.ButterKnife; | ||
| 20 | +import butterknife.OnClick; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Created by abao on 2017/5/5. | ||
| 24 | + * @deprecated | ||
| 25 | + */ | ||
| 26 | + | ||
| 27 | +public class AnswerSheetView extends RelativeLayout { | ||
| 28 | + /*单选多选类型*/ | ||
| 29 | + public final static int ANSWER_TYPE_SINGLE_OR_MORE = 1; | ||
| 30 | + /*对错类型*/ | ||
| 31 | + public final static int ANSWER_TYPE_RIGHT_OR_WRONG = 2; | ||
| 32 | + /*填空*/ | ||
| 33 | + public final static int ANSWER_TYPE_FILLING = 3; | ||
| 34 | + /*单前的type*/ | ||
| 35 | + private static int ANSWER_CURRENT_TYPE = 1; | ||
| 36 | + /*倒计时时间 s*/ | ||
| 37 | + public static int ANSWER_TIMEOUT = 30; | ||
| 38 | + @BindView(R.id.tv_exam_countdown) | ||
| 39 | + TextView tvExamCountdown; | ||
| 40 | + @BindView(R.id.rel_home_tv_exam_countdown) | ||
| 41 | + RelativeLayout relHomeTvExamCountdown; | ||
| 42 | + @BindView(R.id.cb_exam_A) | ||
| 43 | + CheckBox cbExamA; | ||
| 44 | + @BindView(R.id.cb_exam_B) | ||
| 45 | + CheckBox cbExamB; | ||
| 46 | + @BindView(R.id.cb_exam_C) | ||
| 47 | + CheckBox cbExamC; | ||
| 48 | + @BindView(R.id.cb_exam_D) | ||
| 49 | + CheckBox cbExamD; | ||
| 50 | + @BindView(R.id.ll_exam_SingleOrMore) | ||
| 51 | + LinearLayout llExamSingleOrMore; | ||
| 52 | + @BindView(R.id.rb_exam_R) | ||
| 53 | + RadioButton rbExamR; | ||
| 54 | + @BindView(R.id.rb_exam_W) | ||
| 55 | + RadioButton rbExamW; | ||
| 56 | + @BindView(R.id.ll_exam_selectRightOrWrong) | ||
| 57 | + LinearLayout llExamSelectRightOrWrong; | ||
| 58 | + @BindView(R.id.ll_exam_filling) | ||
| 59 | + LinearLayout llExamFilling; | ||
| 60 | + @BindView(R.id.tv_exam_up) | ||
| 61 | + TextView tvExamUp; | ||
| 62 | + @BindView(R.id.tv_exam_cancle) | ||
| 63 | + TextView tvExamCancle; | ||
| 64 | + @BindView(R.id.ll_exam_submit) | ||
| 65 | + LinearLayout llExamSubmit; | ||
| 66 | + @BindView(R.id.rel_exam_layout) | ||
| 67 | + RelativeLayout relExamLayout; | ||
| 68 | + @BindView(R.id.ll_exam_answer) | ||
| 69 | + LinearLayout llExamAnswer; | ||
| 70 | + | ||
| 71 | + private AnswerCount mAnswerCount; | ||
| 72 | + | ||
| 73 | + private StringBuffer sb = new StringBuffer(); | ||
| 74 | + private Context mContext; | ||
| 75 | + private String character_close="关闭"; | ||
| 76 | + private String character_cancle="放弃"; | ||
| 77 | + Display display; | ||
| 78 | + | ||
| 79 | + private OnAnswerLayoutChangeListener onAnswerLayoutChangeListener; | ||
| 80 | + public interface OnAnswerLayoutChangeListener{ | ||
| 81 | + /** | ||
| 82 | + * 改变显示布局的大小 | ||
| 83 | + * @param | ||
| 84 | + */ | ||
| 85 | + void setAnswerSheetFramLayout(int num); | ||
| 86 | + | ||
| 87 | + void setAnswerSheetNormal(int num); | ||
| 88 | + } | ||
| 89 | + public void setOnAnswerLayoutChangeListener(OnAnswerLayoutChangeListener onAnswerLayoutChangeListener){ | ||
| 90 | + this.onAnswerLayoutChangeListener=onAnswerLayoutChangeListener; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + | ||
| 94 | + | ||
| 95 | + public AnswerSheetView(Context context) { | ||
| 96 | + this(context, null); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public AnswerSheetView(Context context, AttributeSet attrs) { | ||
| 100 | + this(context, attrs, 0); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + public AnswerSheetView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
| 104 | + super(context, attrs, defStyleAttr); | ||
| 105 | + mContext = context; | ||
| 106 | + View view = initView(context); | ||
| 107 | + | ||
| 108 | + this.addView(view); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + public View initView(Context context) { | ||
| 112 | + View view = LayoutInflater.from(context).inflate(R.layout.item_answer, null); | ||
| 113 | + ButterKnife.bind(this, view); | ||
| 114 | + return view; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + /*选择答题类型*/ | ||
| 118 | + public void selectAnswerSheetType(int type) { | ||
| 119 | + tvExamCountdown.setText("_s"); | ||
| 120 | + llExamAnswer.setVisibility(View.GONE); | ||
| 121 | + tvExamUp.setVisibility(View.VISIBLE); | ||
| 122 | + tvExamCancle.setText(character_cancle); | ||
| 123 | + switch (type) { | ||
| 124 | + case ANSWER_TYPE_SINGLE_OR_MORE: | ||
| 125 | + ANSWER_CURRENT_TYPE = ANSWER_TYPE_SINGLE_OR_MORE; | ||
| 126 | + llExamSingleOrMore.setVisibility(View.VISIBLE); | ||
| 127 | + llExamSelectRightOrWrong.setVisibility(View.GONE); | ||
| 128 | + llExamFilling.setVisibility(View.GONE); | ||
| 129 | + break; | ||
| 130 | + case ANSWER_TYPE_RIGHT_OR_WRONG: | ||
| 131 | + ANSWER_CURRENT_TYPE = ANSWER_TYPE_RIGHT_OR_WRONG; | ||
| 132 | + llExamSingleOrMore.setVisibility(View.GONE); | ||
| 133 | + llExamSelectRightOrWrong.setVisibility(View.VISIBLE); | ||
| 134 | + llExamFilling.setVisibility(View.GONE); | ||
| 135 | + break; | ||
| 136 | + case ANSWER_TYPE_FILLING: | ||
| 137 | + ANSWER_CURRENT_TYPE = ANSWER_TYPE_FILLING; | ||
| 138 | + llExamSingleOrMore.setVisibility(View.GONE); | ||
| 139 | + llExamSelectRightOrWrong.setVisibility(View.GONE); | ||
| 140 | + llExamFilling.setVisibility(View.VISIBLE); | ||
| 141 | + break; | ||
| 142 | + | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + @OnClick({R.id.tv_exam_up, R.id.tv_exam_cancle}) | ||
| 147 | + public void onViewClicked(View view) { | ||
| 148 | + switch (view.getId()) { | ||
| 149 | + case R.id.tv_exam_up: | ||
| 150 | + //提交需要获取结果,清除数据,时间清理 | ||
| 151 | +// relExamLayout.setVisibility(GONE); | ||
| 152 | + handleAnswer(ANSWER_CURRENT_TYPE); | ||
| 153 | + ToastUtil.showToastshort("选择答案:" + sb.toString() + sb.length(), mContext); | ||
| 154 | + recoverStatus(); | ||
| 155 | + setSubmitAnswer(); | ||
| 156 | + break; | ||
| 157 | + case R.id.tv_exam_cancle: | ||
| 158 | + recoverStatus(); | ||
| 159 | +// if(character_cancle.equals(tvExamCancle)) { | ||
| 160 | +// setAnsNormalLayout(53); | ||
| 161 | +// }else{ | ||
| 162 | +// | ||
| 163 | +// } | ||
| 164 | + if(relExamLayout.isShown()){ | ||
| 165 | + relExamLayout.setVisibility(GONE); | ||
| 166 | + } | ||
| 167 | + break; | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + /*开始倒计时*/ | ||
| 172 | + public void startCountTimer(int time) { | ||
| 173 | + ANSWER_TIMEOUT = time; | ||
| 174 | + cancleCountTimer(); | ||
| 175 | + mAnswerCount = new AnswerCount(ANSWER_TIMEOUT * 1000, 1000); | ||
| 176 | + mAnswerCount.start(); | ||
| 177 | + //提交需要获取结果,清除数据,时间清理 | ||
| 178 | + relExamLayout.setVisibility(VISIBLE); | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + /*销毁倒计时*/ | ||
| 182 | + public void cancleCountTimer() { | ||
| 183 | + if (mAnswerCount != null) { | ||
| 184 | + mAnswerCount.cancel(); | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + /** | ||
| 189 | + * 处理结果,拼装答案 | ||
| 190 | + * | ||
| 191 | + * @param type | ||
| 192 | + */ | ||
| 193 | + public void handleAnswer(int type) { | ||
| 194 | + switch (type) { | ||
| 195 | + case ANSWER_TYPE_SINGLE_OR_MORE: | ||
| 196 | + handleSingleOrMore(); | ||
| 197 | + break; | ||
| 198 | + case ANSWER_TYPE_RIGHT_OR_WRONG: | ||
| 199 | + handleRightOrWrong(); | ||
| 200 | + break; | ||
| 201 | + case ANSWER_TYPE_FILLING: | ||
| 202 | + | ||
| 203 | + break; | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + /*单选,多选答案拼接*/ | ||
| 209 | + public void handleSingleOrMore() { | ||
| 210 | + sb.setLength(0); | ||
| 211 | + if (cbExamA.isChecked()) { | ||
| 212 | + sb.append("A"); | ||
| 213 | + } | ||
| 214 | + if (cbExamB.isChecked()) { | ||
| 215 | + sb.append("B"); | ||
| 216 | + } | ||
| 217 | + if (cbExamC.isChecked()) { | ||
| 218 | + sb.append("C"); | ||
| 219 | + } | ||
| 220 | + if (cbExamD.isChecked()) { | ||
| 221 | + sb.append("D"); | ||
| 222 | + } | ||
| 223 | + | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + /*处理对错*/ | ||
| 227 | + public void handleRightOrWrong() { | ||
| 228 | + sb.setLength(0); | ||
| 229 | + if (rbExamR.isChecked()) { | ||
| 230 | + sb.append("对"); | ||
| 231 | + } else { | ||
| 232 | + sb.append("错"); | ||
| 233 | + } | ||
| 234 | + | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + /*恢复状态*/ | ||
| 238 | + public void recoverStatus() { | ||
| 239 | + switch (ANSWER_CURRENT_TYPE) { | ||
| 240 | + case ANSWER_TYPE_SINGLE_OR_MORE: | ||
| 241 | + cbExamA.setChecked(false); | ||
| 242 | + cbExamB.setChecked(false); | ||
| 243 | + cbExamC.setChecked(false); | ||
| 244 | + cbExamD.setChecked(false); | ||
| 245 | + break; | ||
| 246 | + case ANSWER_TYPE_RIGHT_OR_WRONG: | ||
| 247 | + rbExamR.setChecked(true); | ||
| 248 | + rbExamW.setChecked(false); | ||
| 249 | + break; | ||
| 250 | + case ANSWER_TYPE_FILLING: | ||
| 251 | + break; | ||
| 252 | + } | ||
| 253 | + } | ||
| 254 | + /*隐藏所有题目*/ | ||
| 255 | + private void hideAllTitle(){ | ||
| 256 | + llExamSingleOrMore.setVisibility(View.GONE); | ||
| 257 | + llExamSelectRightOrWrong.setVisibility(View.GONE); | ||
| 258 | + llExamFilling.setVisibility(View.GONE); | ||
| 259 | + } | ||
| 260 | + /*设置显示答案布局大小*/ | ||
| 261 | + public void setAnswerLayout(int num){ | ||
| 262 | + if(onAnswerLayoutChangeListener!=null) { | ||
| 263 | + onAnswerLayoutChangeListener.setAnswerSheetFramLayout(num); | ||
| 264 | + } | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + /*设置显示答案布局大小*/ | ||
| 268 | + public void setAnsNormalLayout(int num){ | ||
| 269 | + if(onAnswerLayoutChangeListener!=null) { | ||
| 270 | + onAnswerLayoutChangeListener.setAnswerSheetNormal(num); | ||
| 271 | + } | ||
| 272 | + } | ||
| 273 | + /*提交答案 设置*/ | ||
| 274 | + private void setSubmitAnswer(){ | ||
| 275 | + hideAllTitle(); | ||
| 276 | + llExamAnswer.setVisibility(View.VISIBLE); | ||
| 277 | + cancleCountTimer(); | ||
| 278 | + tvExamUp.setVisibility(View.GONE); | ||
| 279 | + tvExamCancle.setText(character_close); | ||
| 280 | + setAnswerLayout(100); | ||
| 281 | + | ||
| 282 | + } | ||
| 283 | + @OnClick(R.id.ll_exam_answer) | ||
| 284 | + public void onViewClicked() { | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + /*倒计时处理*/ | ||
| 288 | + class AnswerCount extends CountDownTimer { | ||
| 289 | + | ||
| 290 | + /** | ||
| 291 | + * @param millisInFuture The number of millis in the future from the call | ||
| 292 | + * to {@link #start()} until the countdown is done and {@link #onFinish()} | ||
| 293 | + * is called. | ||
| 294 | + * @param countDownInterval The interval along the way to receive | ||
| 295 | + * {@link #onTick(long)} callbacks. | ||
| 296 | + */ | ||
| 297 | + public AnswerCount(long millisInFuture, long countDownInterval) { | ||
| 298 | + super(millisInFuture, countDownInterval); | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + @Override | ||
| 302 | + public void onTick(long millisUntilFinished) { | ||
| 303 | + if (millisUntilFinished < 10) { | ||
| 304 | + tvExamCountdown.setText(" " + millisUntilFinished / 1000 + "s"); | ||
| 305 | + } else { | ||
| 306 | + tvExamCountdown.setText(millisUntilFinished / 1000 + "s"); | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + @Override | ||
| 312 | + public void onFinish() { | ||
| 313 | + //这个结束应该做自动提交答案的工作 | ||
| 314 | + tvExamCountdown.setText("0s"); | ||
| 315 | + } | ||
| 316 | + } | ||
| 317 | +} |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.widget.chat; | 16 | +package com.mang.xuedianyun.android.widget.chat; |
| 17 | 17 | ||
| 18 | import android.os.Bundle; | 18 | import android.os.Bundle; |
| 19 | import android.view.LayoutInflater; | 19 | import android.view.LayoutInflater; |
| @@ -22,7 +22,7 @@ import android.view.ViewGroup; | @@ -22,7 +22,7 @@ import android.view.ViewGroup; | ||
| 22 | import android.widget.LinearLayout; | 22 | import android.widget.LinearLayout; |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | -import com.mang.xdy.demo.R; | 25 | +import com.mang.xuedianyun.android.R; |
| 26 | 26 | ||
| 27 | import org.kymjs.kjframe.ui.SupportFragment; | 27 | import org.kymjs.kjframe.ui.SupportFragment; |
| 28 | 28 |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.widget.chat; | 16 | +package com.mang.xuedianyun.android.widget.chat; |
| 17 | 17 | ||
| 18 | import android.app.Activity; | 18 | import android.app.Activity; |
| 19 | import android.graphics.Color; | 19 | import android.graphics.Color; |
| @@ -36,9 +36,9 @@ import android.widget.RadioButton; | @@ -36,9 +36,9 @@ import android.widget.RadioButton; | ||
| 36 | import android.widget.RadioGroup; | 36 | import android.widget.RadioGroup; |
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | -import com.mang.xdy.demo.R; | ||
| 40 | -import com.mang.xdy.demo.adapter.FaceAdapter; | ||
| 41 | -import com.mang.xdy.demo.bean.Faceicon; | 39 | +import com.mang.xuedianyun.android.R; |
| 40 | +import com.mang.xuedianyun.android.adapter.FaceAdapter; | ||
| 41 | +import com.mang.xuedianyun.android.bean.Faceicon; | ||
| 42 | 42 | ||
| 43 | import org.kymjs.kjframe.ui.SupportFragment; | 43 | import org.kymjs.kjframe.ui.SupportFragment; |
| 44 | import org.kymjs.kjframe.utils.StringUtils; | 44 | import org.kymjs.kjframe.utils.StringUtils; |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.widget.chat; | 16 | +package com.mang.xuedianyun.android.widget.chat; |
| 17 | 17 | ||
| 18 | import android.app.Activity; | 18 | import android.app.Activity; |
| 19 | import android.content.Context; | 19 | import android.content.Context; |
| @@ -29,8 +29,8 @@ import android.widget.LinearLayout; | @@ -29,8 +29,8 @@ import android.widget.LinearLayout; | ||
| 29 | import android.widget.RelativeLayout; | 29 | import android.widget.RelativeLayout; |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | -import com.mang.xdy.demo.R; | ||
| 33 | -import com.mang.xdy.demo.adapter.FaceCategroyAdapter; | 32 | +import com.mang.xuedianyun.android.R; |
| 33 | +import com.mang.xuedianyun.android.adapter.FaceCategroyAdapter; | ||
| 34 | 34 | ||
| 35 | import java.util.List; | 35 | import java.util.List; |
| 36 | 36 |
| @@ -13,10 +13,10 @@ | @@ -13,10 +13,10 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.widget.chat; | 16 | +package com.mang.xuedianyun.android.widget.chat; |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | -import com.mang.xdy.demo.bean.Faceicon; | 19 | +import com.mang.xuedianyun.android.bean.Faceicon; |
| 20 | 20 | ||
| 21 | /** | 21 | /** |
| 22 | * 表情栏顶部按钮的监听器 | 22 | * 表情栏顶部按钮的监听器 |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.widget.chat; | 16 | +package com.mang.xuedianyun.android.widget.chat; |
| 17 | 17 | ||
| 18 | import android.annotation.SuppressLint; | 18 | import android.annotation.SuppressLint; |
| 19 | import android.content.Context; | 19 | import android.content.Context; |
| @@ -39,7 +39,7 @@ import android.widget.LinearLayout; | @@ -39,7 +39,7 @@ import android.widget.LinearLayout; | ||
| 39 | import android.widget.TextView; | 39 | import android.widget.TextView; |
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | -import com.mang.xdy.demo.R; | 42 | +import com.mang.xuedianyun.android.R; |
| 43 | 43 | ||
| 44 | import java.util.Locale; | 44 | import java.util.Locale; |
| 45 | 45 |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.widget.chat; | 16 | +package com.mang.xuedianyun.android.widget.chat; |
| 17 | 17 | ||
| 18 | import android.graphics.Rect; | 18 | import android.graphics.Rect; |
| 19 | import android.view.View; | 19 | import android.view.View; |
MyApplication/XdyDemo/src/main/java/com/mang/xuedianyun/android/widget/dialog/AnswText.java
0 → 100644
| 1 | +package com.mang.xuedianyun.android.widget.dialog; | ||
| 2 | + | ||
| 3 | +import android.app.Dialog; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.view.Display; | ||
| 6 | +import android.view.Gravity; | ||
| 7 | +import android.view.LayoutInflater; | ||
| 8 | +import android.view.View; | ||
| 9 | +import android.view.Window; | ||
| 10 | +import android.view.WindowManager; | ||
| 11 | +import android.widget.LinearLayout; | ||
| 12 | +import android.widget.ScrollView; | ||
| 13 | +import android.widget.TextView; | ||
| 14 | + | ||
| 15 | +import com.mang.xuedianyun.android.R; | ||
| 16 | + | ||
| 17 | +import butterknife.ButterKnife; | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Created by abao on 2017/5/9. | ||
| 22 | + * @deprecated | ||
| 23 | + */ | ||
| 24 | + | ||
| 25 | +public class AnswText { | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + /*单选多选类型*/ | ||
| 33 | + public final static int ANSWER_TYPE_SINGLE_OR_MORE = 1; | ||
| 34 | + /*对错类型*/ | ||
| 35 | + public final static int ANSWER_TYPE_RIGHT_OR_WRONG = 2; | ||
| 36 | + /*填空*/ | ||
| 37 | + public final static int ANSWER_TYPE_FILLING = 3; | ||
| 38 | + /*单前的type*/ | ||
| 39 | + private static int ANSWER_CURRENT_TYPE = 1; | ||
| 40 | + /*倒计时时间 s*/ | ||
| 41 | + public static int ANSWER_TIMEOUT = 30; | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + private StringBuffer sb = new StringBuffer(); | ||
| 46 | + private Context mContext; | ||
| 47 | + private String character_close="关闭"; | ||
| 48 | + private String character_cancle="放弃"; | ||
| 49 | + | ||
| 50 | + private OnAnswerLayoutChangeListener onAnswerLayoutChangeListener; | ||
| 51 | + public interface OnAnswerLayoutChangeListener{ | ||
| 52 | + /** | ||
| 53 | + * 改变显示布局的大小 | ||
| 54 | + * @param | ||
| 55 | + */ | ||
| 56 | + void setAnswerSheetFramLayout(int num); | ||
| 57 | + | ||
| 58 | + void setAnswerSheetNormal(int num); | ||
| 59 | + } | ||
| 60 | + public void setOnAnswerLayoutChangeListener(OnAnswerLayoutChangeListener onAnswerLayoutChangeListener){ | ||
| 61 | + this.onAnswerLayoutChangeListener=onAnswerLayoutChangeListener; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + private Context context; | ||
| 65 | + private Dialog dialog; | ||
| 66 | + private TextView txt_title; | ||
| 67 | + private TextView txt_cancel; | ||
| 68 | + private LinearLayout lLayout_content; | ||
| 69 | + private ScrollView sLayout_content; | ||
| 70 | + private boolean showTitle = false; | ||
| 71 | +// private List<ActionSheetDialog.SheetItem> sheetItemList; | ||
| 72 | + private Display display; | ||
| 73 | + | ||
| 74 | + public AnswText(Context context) { | ||
| 75 | + this.context = context; | ||
| 76 | + this.mContext=context; | ||
| 77 | + WindowManager windowManager = (WindowManager) context | ||
| 78 | + .getSystemService(Context.WINDOW_SERVICE); | ||
| 79 | + display = windowManager.getDefaultDisplay(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public AnswText builder() { | ||
| 83 | + View view = LayoutInflater.from(context).inflate( | ||
| 84 | + R.layout.view_text, null); | ||
| 85 | + ButterKnife.bind(this,view); | ||
| 86 | + view.setMinimumWidth(display.getWidth()); | ||
| 87 | + | ||
| 88 | + dialog = new Dialog(context, R.style.ActionSheetDialogStyle); | ||
| 89 | + dialog.setContentView(view); | ||
| 90 | + Window dialogWindow = dialog.getWindow(); | ||
| 91 | + dialogWindow.setGravity(Gravity.LEFT | Gravity.BOTTOM); | ||
| 92 | +// dialogWindow.setGravity( Gravity.BOTTOM); | ||
| 93 | + WindowManager.LayoutParams lp = dialogWindow.getAttributes(); | ||
| 94 | + lp.x = 0; | ||
| 95 | + lp.y = 0; | ||
| 96 | + dialogWindow.setAttributes(lp); | ||
| 97 | + return this; | ||
| 98 | + } | ||
| 99 | + public void show() { | ||
| 100 | + dialog.show(); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + | ||
| 104 | + | ||
| 105 | +} | ||
| 106 | + |
| 1 | -package com.mang.xdy.demo.widget.dialog; | 1 | +package com.mang.xuedianyun.android.widget.dialog; |
| 2 | 2 | ||
| 3 | import android.app.Dialog; | 3 | import android.app.Dialog; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| @@ -12,15 +12,14 @@ import android.view.ViewGroup; | @@ -12,15 +12,14 @@ import android.view.ViewGroup; | ||
| 12 | import android.view.Window; | 12 | import android.view.Window; |
| 13 | import android.view.WindowManager; | 13 | import android.view.WindowManager; |
| 14 | import android.widget.CheckBox; | 14 | import android.widget.CheckBox; |
| 15 | -import android.widget.ImageView; | ||
| 16 | import android.widget.LinearLayout; | 15 | import android.widget.LinearLayout; |
| 17 | import android.widget.RadioButton; | 16 | import android.widget.RadioButton; |
| 18 | import android.widget.RelativeLayout; | 17 | import android.widget.RelativeLayout; |
| 19 | import android.widget.ScrollView; | 18 | import android.widget.ScrollView; |
| 20 | import android.widget.TextView; | 19 | import android.widget.TextView; |
| 21 | 20 | ||
| 22 | -import com.mang.xdy.demo.R; | ||
| 23 | -import com.mang.xdy.demo.utils.ToastUtil; | 21 | +import com.mang.xuedianyun.android.R; |
| 22 | +import com.mang.xuedianyun.android.utils.ToastUtil; | ||
| 24 | import com.mang.xdy.utils.XdyLogUtil; | 23 | import com.mang.xdy.utils.XdyLogUtil; |
| 25 | import com.mang.xdy.utils.XdyStringUtils; | 24 | import com.mang.xdy.utils.XdyStringUtils; |
| 26 | 25 |
| 1 | -package com.mang.xdy.demo.widget.dialog; | 1 | +package com.mang.xuedianyun.android.widget.dialog; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.view.Gravity; | 4 | import android.view.Gravity; |
| @@ -7,8 +7,8 @@ import android.widget.Button; | @@ -7,8 +7,8 @@ import android.widget.Button; | ||
| 7 | import android.widget.EditText; | 7 | import android.widget.EditText; |
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | -import com.mang.xdy.demo.R; | ||
| 11 | -import com.mang.xdy.demo.dialog.BaseDialog; | 10 | +import com.mang.xuedianyun.android.R; |
| 11 | +import com.mang.xuedianyun.android.dialog.BaseDialog; | ||
| 12 | import com.mang.xdy.utils.UIUtils; | 12 | import com.mang.xdy.utils.UIUtils; |
| 13 | 13 | ||
| 14 | import org.greenrobot.eventbus.EventBus; | 14 | import org.greenrobot.eventbus.EventBus; |
| @@ -13,13 +13,13 @@ | @@ -13,13 +13,13 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.widget.emoji; | 16 | +package com.mang.xuedianyun.android.widget.emoji; |
| 17 | 17 | ||
| 18 | import android.widget.AbsListView; | 18 | import android.widget.AbsListView; |
| 19 | import android.widget.TextView; | 19 | import android.widget.TextView; |
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | -import com.mang.xdy.demo.R; | 22 | +import com.mang.xuedianyun.android.R; |
| 23 | 23 | ||
| 24 | import org.kymjs.kjframe.widget.AdapterHolder; | 24 | import org.kymjs.kjframe.widget.AdapterHolder; |
| 25 | import org.kymjs.kjframe.widget.KJAdapter; | 25 | import org.kymjs.kjframe.widget.KJAdapter; |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.widget.emoji; | 16 | +package com.mang.xuedianyun.android.widget.emoji; |
| 17 | 17 | ||
| 18 | import android.app.Activity; | 18 | import android.app.Activity; |
| 19 | import android.os.Bundle; | 19 | import android.os.Bundle; |
| @@ -31,8 +31,8 @@ import android.widget.RadioButton; | @@ -31,8 +31,8 @@ import android.widget.RadioButton; | ||
| 31 | import android.widget.RadioGroup; | 31 | import android.widget.RadioGroup; |
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | -import com.mang.xdy.demo.R; | ||
| 35 | -import com.mang.xdy.demo.widget.chat.OnOperationListener; | 34 | +import com.mang.xuedianyun.android.R; |
| 35 | +import com.mang.xuedianyun.android.widget.chat.OnOperationListener; | ||
| 36 | 36 | ||
| 37 | import org.kymjs.kjframe.ui.SupportFragment; | 37 | import org.kymjs.kjframe.ui.SupportFragment; |
| 38 | 38 |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | -package com.mang.xdy.demo.widget.emoji; | 16 | +package com.mang.xuedianyun.android.widget.emoji; |
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| 19 | * emoji表情的javabean | 19 | * emoji表情的javabean |
| 1 | -package com.mang.xdy.demo.widget.view; | 1 | +package com.mang.xuedianyun.android.widget.view; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.os.Build; | 4 | import android.os.Build; |
| @@ -7,7 +7,7 @@ import android.view.View; | @@ -7,7 +7,7 @@ import android.view.View; | ||
| 7 | import android.view.ViewGroup; | 7 | import android.view.ViewGroup; |
| 8 | import android.widget.RelativeLayout; | 8 | import android.widget.RelativeLayout; |
| 9 | 9 | ||
| 10 | -import com.mang.xdy.demo.utils.DisplayUtil; | 10 | +import com.mang.xuedianyun.android.utils.DisplayUtil; |
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | public class AutoAdaptHeaderViewGroup extends RelativeLayout { | 13 | public class AutoAdaptHeaderViewGroup extends RelativeLayout { |
1.7 KB
1.7 KB
2.3 KB
2.0 KB
1.6 KB
2.7 KB
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:drawable="@color/home_btn_green_press" android:state_pressed="true"></item> | ||
| 4 | + <item android:drawable="@color/home_btn_green_press" android:state_checked="true"></item> | ||
| 5 | + <item android:drawable="@color/home_btn_green"></item> | ||
| 6 | +</selector> |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="oval" | ||
| 5 | + android:useLevel="false" > | ||
| 6 | + <solid android:color="@color/colorSkyBlue" /> | ||
| 7 | + <!--<padding--> | ||
| 8 | + <!--android:left="2dp"--> | ||
| 9 | + <!--android:top="1dp"--> | ||
| 10 | + <!--android:right="2dp"--> | ||
| 11 | + <!--android:bottom="1dp" />--> | ||
| 12 | + <!--<solid--> | ||
| 13 | + <!--android:color="@color/actionsheet_red" />--> | ||
| 14 | + <!--<stroke--> | ||
| 15 | + <!--android:width="1dp"--> | ||
| 16 | + <!--android:color="@android:color/white" />--> | ||
| 17 | + <size android:width="18dp" | ||
| 18 | + android:height="18dp" /> | ||
| 19 | +</shape> |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<shape | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + android:shape="oval" | ||
| 5 | + android:useLevel="false" > | ||
| 6 | + <solid android:color="@color/actionsheet_red" /> | ||
| 7 | + <!--<padding--> | ||
| 8 | + <!--android:left="2dp"--> | ||
| 9 | + <!--android:top="1dp"--> | ||
| 10 | + <!--android:right="2dp"--> | ||
| 11 | + <!--android:bottom="1dp" />--> | ||
| 12 | + <!--<solid--> | ||
| 13 | + <!--android:color="@color/actionsheet_red" />--> | ||
| 14 | + <!--<stroke--> | ||
| 15 | + <!--android:width="1dp"--> | ||
| 16 | + <!--android:color="@android:color/white" />--> | ||
| 17 | + <size android:width="18dp" | ||
| 18 | + android:height="18dp" /> | ||
| 19 | +</shape> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:shape="rectangle"> | ||
| 4 | + | ||
| 5 | + <!-- 圆角 --> | ||
| 6 | + <corners android:radius="16dp" /> | ||
| 7 | + | ||
| 8 | + <!-- 填充颜色 --> | ||
| 9 | + <solid android:color="@color/colorSkyBlue" /> | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + <!--<!–内边距–>--> | ||
| 13 | + <padding | ||
| 14 | + android:bottom="5dp" | ||
| 15 | + android:left="5dp" | ||
| 16 | + android:right="5dp" | ||
| 17 | + android:top="5dp" /> | ||
| 18 | +</shape> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:shape="rectangle"> | ||
| 4 | + | ||
| 5 | + <!-- 圆角 --> | ||
| 6 | + <corners android:radius="16dp" /> | ||
| 7 | + | ||
| 8 | + <!-- 填充颜色 --> | ||
| 9 | + <solid android:color="@color/colorGrey" /> | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + <!--内边距--> | ||
| 13 | + <padding | ||
| 14 | + android:bottom="5dp" | ||
| 15 | + android:left="5dp" | ||
| 16 | + android:right="5dp" | ||
| 17 | + android:top="5dp" /> | ||
| 18 | +</shape> |
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
| 6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
| 7 | android:orientation="vertical" | 7 | android:orientation="vertical" |
| 8 | - tools:context="com.mang.xdy.demo.MainActivity"> | 8 | + tools:context="com.mang.xuedianyun.android.MainActivity"> |
| 9 | <RelativeLayout | 9 | <RelativeLayout |
| 10 | android:id="@+id/rl_home_close" | 10 | android:id="@+id/rl_home_close" |
| 11 | android:layout_width="@dimen/ui_DIMEN_98.0PX" | 11 | android:layout_width="@dimen/ui_DIMEN_98.0PX" |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 4 | + xmlns:custom="http://schemas.android.com/apk/res-auto" | ||
| 5 | + android:id="@+id/activity_video_play" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="match_parent" | ||
| 8 | + android:orientation="vertical" | ||
| 9 | + android:background="#e3e4e6" | ||
| 10 | + tools:context="com.mang.xuedianyun.android.activity.VideoPlayActivity"> | ||
| 11 | + <RelativeLayout | ||
| 12 | + android:id="@+id/avg_videoPlay_back" | ||
| 13 | + android:layout_width="match_parent" | ||
| 14 | + android:layout_height="wrap_content" | ||
| 15 | + android:layout_alignParentLeft="true" | ||
| 16 | + android:layout_alignParentStart="true" | ||
| 17 | + android:layout_alignParentTop="true" | ||
| 18 | + android:paddingLeft="@dimen/ui_DIMEN_20.0PX" | ||
| 19 | + android:paddingRight="@dimen/ui_DIMEN_20.0PX"> | ||
| 20 | + | ||
| 21 | + <ImageView | ||
| 22 | + android:id="@+id/img_videoPlay_back" | ||
| 23 | + android:layout_width="wrap_content" | ||
| 24 | + android:layout_height="@dimen/ui_titlebar_height" | ||
| 25 | + android:paddingRight="10dp" | ||
| 26 | + android:paddingLeft="15dp" | ||
| 27 | + android:src="@mipmap/back"/> | ||
| 28 | + <TextView | ||
| 29 | + android:layout_toRightOf="@+id/img_videoPlay_back" | ||
| 30 | + android:layout_width="wrap_content" | ||
| 31 | + style="@style/ui_wrapTvBaseStyle" | ||
| 32 | + android:layout_height="@dimen/ui_titlebar_height" | ||
| 33 | + android:text="@string/home_title_back" | ||
| 34 | + android:gravity="center" | ||
| 35 | + android:textColor="@color/white" | ||
| 36 | + android:visibility="gone" | ||
| 37 | + /> | ||
| 38 | + <TextView | ||
| 39 | + android:id="@+id/tv_videoPlay_className" | ||
| 40 | + style="@style/ui_wrapTvBaseStyle" | ||
| 41 | + android:layout_height="@dimen/ui_titlebar_height" | ||
| 42 | + android:gravity="center" | ||
| 43 | + android:layout_centerHorizontal="true" | ||
| 44 | + android:textColor="@color/white" | ||
| 45 | + android:layout_toRightOf="@+id/img_videoPlay_back" | ||
| 46 | + tools:text="dfdfdfdfdfdf" | ||
| 47 | + android:textSize="@dimen/ui_DIMEN_34.0PX"/> | ||
| 48 | + </RelativeLayout> | ||
| 49 | + <!--白板+right--> | ||
| 50 | + <RelativeLayout | ||
| 51 | + android:layout_width="match_parent" | ||
| 52 | + android:layout_height="match_parent" | ||
| 53 | + android:orientation="horizontal" | ||
| 54 | + android:layout_below="@+id/avg_videoPlay_back" | ||
| 55 | + android:layout_above="@+id/fl_media" | ||
| 56 | + > | ||
| 57 | + | ||
| 58 | + <LinearLayout | ||
| 59 | + android:id="@+id/ll_videoPlay_right" | ||
| 60 | + android:layout_width="wrap_content" | ||
| 61 | + android:layout_height="match_parent" | ||
| 62 | + android:layout_weight="1" | ||
| 63 | + android:orientation="vertical" | ||
| 64 | + android:layout_alignParentRight="true" | ||
| 65 | + > | ||
| 66 | + <RelativeLayout | ||
| 67 | + android:id="@+id/rel_videoPlay_play" | ||
| 68 | + android:layout_width="255dp" | ||
| 69 | + android:layout_alignParentRight="true" | ||
| 70 | + android:layout_weight="1" | ||
| 71 | + android:layout_height="wrap_content"> | ||
| 72 | + <com.pili.pldroid.player.widget.PLVideoTextureView | ||
| 73 | + android:id="@+id/img_playVideo_replay" | ||
| 74 | + android:layout_width="match_parent" | ||
| 75 | + android:layout_height="match_parent" | ||
| 76 | + android:layout_gravity="center"/> | ||
| 77 | + <SurfaceView | ||
| 78 | + android:id="@+id/surfaceview_playVideo" | ||
| 79 | + android:layout_width="match_parent" | ||
| 80 | + android:layout_height="match_parent" | ||
| 81 | + /> | ||
| 82 | + <ImageView | ||
| 83 | + android:id="@+id/img_playVideo_novideo" | ||
| 84 | + android:layout_width="match_parent" | ||
| 85 | + android:layout_height="match_parent" | ||
| 86 | + android:background="@mipmap/novideo" | ||
| 87 | + /> | ||
| 88 | + <FrameLayout | ||
| 89 | + android:layout_width="match_parent" | ||
| 90 | + android:layout_height="wrap_content"> | ||
| 91 | + | ||
| 92 | + </FrameLayout> | ||
| 93 | + <LinearLayout | ||
| 94 | + android:layout_width="wrap_content" | ||
| 95 | + android:layout_height="wrap_content" | ||
| 96 | + android:orientation="vertical" | ||
| 97 | + android:layout_alignParentRight="true" | ||
| 98 | + android:id="@+id/linearLayout"> | ||
| 99 | + | ||
| 100 | + </LinearLayout> | ||
| 101 | + | ||
| 102 | + | ||
| 103 | + | ||
| 104 | + </RelativeLayout> | ||
| 105 | + | ||
| 106 | + <!--推流--> | ||
| 107 | + <RelativeLayout | ||
| 108 | + android:id="@+id/rel_videoPlay_publish" | ||
| 109 | + android:layout_width="255dp" | ||
| 110 | + android:layout_height="wrap_content" | ||
| 111 | + android:layout_weight="1" | ||
| 112 | + android:layout_below="@+id/rel_videoPlay_play" | ||
| 113 | + android:layout_alignParentRight="true" | ||
| 114 | + android:layout_alignLeft="@+id/rel_videoPlay_play" | ||
| 115 | + android:layout_marginTop="8dp" | ||
| 116 | + > | ||
| 117 | + | ||
| 118 | + <SurfaceView | ||
| 119 | + android:id="@+id/sur_plaVideo_publish" | ||
| 120 | + android:layout_width="match_parent" | ||
| 121 | + android:layout_height="match_parent" | ||
| 122 | + android:visibility="gone" | ||
| 123 | + tools:visibility="visible" | ||
| 124 | + android:layout_alignParentRight="true" | ||
| 125 | + android:layout_alignParentBottom="true" | ||
| 126 | + /> | ||
| 127 | + <FrameLayout | ||
| 128 | + android:id="@+id/fra_videoPlay_student_cover" | ||
| 129 | + android:layout_width="match_parent" | ||
| 130 | + android:layout_height="match_parent" | ||
| 131 | + android:layout_centerInParent="true" | ||
| 132 | + > | ||
| 133 | + <ImageView | ||
| 134 | + android:layout_width="wrap_content" | ||
| 135 | + android:layout_height="wrap_content" | ||
| 136 | + android:background="@mipmap/student" | ||
| 137 | + tools:visibility="visible" | ||
| 138 | + android:layout_gravity="center" | ||
| 139 | + android:scaleType="fitCenter" | ||
| 140 | + /> | ||
| 141 | + </FrameLayout> | ||
| 142 | + | ||
| 143 | + <ImageView | ||
| 144 | + android:id="@+id/img_playVideo_publishAudio" | ||
| 145 | + android:layout_width="match_parent" | ||
| 146 | + android:layout_height="match_parent" | ||
| 147 | + android:background="@mipmap/audio_mode" | ||
| 148 | + android:visibility="gone" | ||
| 149 | + tools:visibility="visible" | ||
| 150 | + android:scaleType="fitCenter" | ||
| 151 | + android:layout_alignParentRight="true" | ||
| 152 | + android:layout_alignParentBottom="true" | ||
| 153 | + /> | ||
| 154 | + <FrameLayout | ||
| 155 | + android:id="@+id/fra_videoPlay_start" | ||
| 156 | + android:layout_width="50dp" | ||
| 157 | + android:layout_height="50dp" | ||
| 158 | + | ||
| 159 | + tools:visibility="visible" | ||
| 160 | + android:layout_alignParentLeft="true" | ||
| 161 | + android:layout_alignParentBottom="true" | ||
| 162 | + > | ||
| 163 | + <ImageView | ||
| 164 | + android:id="@+id/img_videoPlay_start" | ||
| 165 | + android:layout_width="20dp" | ||
| 166 | + android:layout_height="12dp" | ||
| 167 | + android:layout_marginTop="20dp" | ||
| 168 | + android:layout_marginLeft="5dp" | ||
| 169 | + android:background="@mipmap/camera_normal2x" | ||
| 170 | + /> | ||
| 171 | + </FrameLayout> | ||
| 172 | + <!--音频--> | ||
| 173 | + <FrameLayout | ||
| 174 | + android:id="@+id/fra_videoPlay_start_audio" | ||
| 175 | + android:layout_width="50dp" | ||
| 176 | + android:layout_height="50dp" | ||
| 177 | + android:layout_toRightOf="@+id/fra_videoPlay_start" | ||
| 178 | + tools:visibility="visible" | ||
| 179 | + android:layout_alignParentBottom="true" | ||
| 180 | + > | ||
| 181 | + <ImageView | ||
| 182 | + android:id="@+id/img_videoPlay_start_audio" | ||
| 183 | + android:layout_width="12dp" | ||
| 184 | + android:layout_height="20dp" | ||
| 185 | + android:layout_marginTop="15dp" | ||
| 186 | + android:background="@mipmap/mic_normal2x" | ||
| 187 | + /> | ||
| 188 | + </FrameLayout> | ||
| 189 | + | ||
| 190 | + <FrameLayout | ||
| 191 | + android:id="@+id/fra_videoPlay_stopPublish" | ||
| 192 | + android:layout_width="70dp" | ||
| 193 | + android:layout_height="50dp" | ||
| 194 | + android:visibility="gone" | ||
| 195 | + tools:visibility="visible" | ||
| 196 | + android:layout_alignParentLeft="true" | ||
| 197 | + android:layout_alignParentBottom="true" | ||
| 198 | + android:layout_alignBottom="@+id/sur_plaVideo_publish" | ||
| 199 | + > | ||
| 200 | + <ImageView | ||
| 201 | + android:id="@+id/img_videoPlay_stopPublish" | ||
| 202 | + android:layout_width="wrap_content" | ||
| 203 | + android:layout_height="wrap_content" | ||
| 204 | + android:layout_marginTop="20dp" | ||
| 205 | + android:layout_marginLeft="15dp" | ||
| 206 | + android:enabled="false" | ||
| 207 | + android:background="@mipmap/hangup_normal2x" | ||
| 208 | + /> | ||
| 209 | + </FrameLayout> | ||
| 210 | + </RelativeLayout> | ||
| 211 | + | ||
| 212 | + <LinearLayout | ||
| 213 | + android:id="@+id/ll_videoPlay_tablet_chat" | ||
| 214 | + android:layout_width="255dp" | ||
| 215 | + android:layout_height="match_parent" | ||
| 216 | + android:orientation="vertical" | ||
| 217 | + android:layout_marginTop="8dp" | ||
| 218 | + /> | ||
| 219 | + </LinearLayout> | ||
| 220 | + <!--Tablet文档--> | ||
| 221 | + <LinearLayout | ||
| 222 | + android:id="@+id/ll_videoPlay_tablet_doc" | ||
| 223 | + android:layout_width="match_parent" | ||
| 224 | + android:layout_height="match_parent" | ||
| 225 | + android:layout_weight="3" | ||
| 226 | + android:orientation="vertical" | ||
| 227 | + android:layout_marginRight="5dp" | ||
| 228 | + android:layout_marginLeft="5dp" | ||
| 229 | + android:layout_toLeftOf="@+id/ll_videoPlay_right" | ||
| 230 | + /> | ||
| 231 | + | ||
| 232 | + </RelativeLayout> | ||
| 233 | + <com.flyco.tablayout.SlidingTabLayout | ||
| 234 | + android:id="@+id/stl_videoPlay_tab" | ||
| 235 | + android:layout_width="match_parent" | ||
| 236 | + android:layout_height="@dimen/ui_titlebar_height" | ||
| 237 | + android:layout_alignParentLeft="true" | ||
| 238 | + android:layout_alignParentStart="true" | ||
| 239 | + android:background="#fafafa" | ||
| 240 | + custom:tl_indicator_color="@color/home_tab_selected" | ||
| 241 | + custom:tl_indicator_corner_radius="1.5dp" | ||
| 242 | + custom:tl_indicator_height="@dimen/ui_DIMEN_5.0PX" | ||
| 243 | + custom:tl_tab_space_equal="true" | ||
| 244 | + custom:tl_textSelectColor="@color/home_tab_selected" | ||
| 245 | + custom:tl_textUnselectColor="@color/home_tab_unselected" | ||
| 246 | + custom:tl_textsize="@dimen/ui_DIMEN_28.0PX"/> | ||
| 247 | + <com.mang.xuedianyun.android.widget.view.NoScrollViewPager | ||
| 248 | + android:id="@+id/viewpager" | ||
| 249 | + android:layout_below="@+id/stl_videoPlay_tab" | ||
| 250 | + android:layout_width="wrap_content" | ||
| 251 | + android:layout_height="wrap_content" | ||
| 252 | + android:layout_alignRight="@+id/stl_videoPlay_tab" | ||
| 253 | + | ||
| 254 | + | ||
| 255 | + android:background="@android:color/white" > | ||
| 256 | + | ||
| 257 | + </com.mang.xuedianyun.android.widget.view.NoScrollViewPager> | ||
| 258 | + | ||
| 259 | + | ||
| 260 | + <FrameLayout | ||
| 261 | + android:id="@+id/fl_media" | ||
| 262 | + android:layout_width="match_parent" | ||
| 263 | + android:layout_height="wrap_content" | ||
| 264 | + android:layout_alignParentBottom="true" | ||
| 265 | + > | ||
| 266 | + <include | ||
| 267 | + layout="@layout/home_media_controller" | ||
| 268 | + android:layout_width="match_parent" | ||
| 269 | + android:layout_height="wrap_content"/> | ||
| 270 | + </FrameLayout> | ||
| 271 | + | ||
| 272 | + | ||
| 273 | +</RelativeLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 4 | + android:id="@+id/activity_video_play" | ||
| 5 | + android:layout_width="match_parent" | ||
| 6 | + android:layout_height="match_parent" | ||
| 7 | + android:orientation="vertical" | ||
| 8 | + tools:context="com.mang.xuedianyun.android.activity.VideoPlayActivity"> | ||
| 9 | + <RelativeLayout | ||
| 10 | + android:layout_width="wrap_content" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + android:visibility="gone" | ||
| 13 | + > | ||
| 14 | + <SurfaceView | ||
| 15 | + android:id="@+id/surfaceview_playVideo" | ||
| 16 | + android:layout_width="match_parent" | ||
| 17 | + android:layout_height="200dp" | ||
| 18 | + android:visibility="gone"/> | ||
| 19 | + <ImageView | ||
| 20 | + android:id="@+id/img_playVideo_novideo" | ||
| 21 | + android:layout_width="match_parent" | ||
| 22 | + android:layout_height="200dp" | ||
| 23 | + android:background="@mipmap/novideo" | ||
| 24 | + /> | ||
| 25 | + </RelativeLayout> | ||
| 26 | + <SurfaceView | ||
| 27 | + android:id="@+id/surfaceview_pubisherVideo" | ||
| 28 | + android:layout_width="match_parent" | ||
| 29 | + android:layout_height="300dp" /> | ||
| 30 | + <android.support.design.widget.TabLayout | ||
| 31 | + android:id="@+id/sliding_tabs" | ||
| 32 | + android:layout_width="match_parent" | ||
| 33 | + android:layout_height="wrap_content" | ||
| 34 | + /> | ||
| 35 | + | ||
| 36 | + <android.support.v4.view.ViewPager | ||
| 37 | + android:id="@+id/viewpager" | ||
| 38 | + android:layout_width="match_parent" | ||
| 39 | + android:layout_height="0px" | ||
| 40 | + android:layout_weight="1" | ||
| 41 | + android:background="@android:color/white" /> | ||
| 42 | + <TextView | ||
| 43 | + android:id="@+id/tv_videoPlay_url" | ||
| 44 | + android:layout_width="wrap_content" | ||
| 45 | + android:layout_height="wrap_content" | ||
| 46 | + /> | ||
| 47 | + <LinearLayout | ||
| 48 | + android:layout_width="match_parent" | ||
| 49 | + android:layout_height="wrap_content" | ||
| 50 | + android:orientation="horizontal"> | ||
| 51 | + <Button | ||
| 52 | + android:id="@+id/btn_videoPlay_chat" | ||
| 53 | + android:layout_width="wrap_content" | ||
| 54 | + android:layout_height="wrap_content" | ||
| 55 | + android:text="发送hello" | ||
| 56 | + android:visibility="gone" | ||
| 57 | + /> | ||
| 58 | + <Button | ||
| 59 | + android:id="@+id/btn_videoPlay_pubsherVideo" | ||
| 60 | + android:layout_width="wrap_content" | ||
| 61 | + android:layout_height="wrap_content" | ||
| 62 | + android:text="获取推流地址推送视频" | ||
| 63 | + android:enabled="false" | ||
| 64 | + /> | ||
| 65 | + <Button | ||
| 66 | + android:id="@+id/btn_videoPlay_publisherAudio" | ||
| 67 | + android:layout_width="wrap_content" | ||
| 68 | + android:layout_height="wrap_content" | ||
| 69 | + android:text="获取推流地址推送音频" | ||
| 70 | + android:enabled="false" | ||
| 71 | + /> | ||
| 72 | + <Button | ||
| 73 | + android:id="@+id/btn_videoPlay_stop" | ||
| 74 | + android:layout_width="wrap_content" | ||
| 75 | + android:layout_height="wrap_content" | ||
| 76 | + android:text="停止推流" | ||
| 77 | + /> | ||
| 78 | + </LinearLayout> | ||
| 79 | +</LinearLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout | ||
| 3 | + android:layout_width="@dimen/ui_DIMEN_500.0PX" | ||
| 4 | + android:layout_height="wrap_content" | ||
| 5 | + android:layout_centerInParent="true" | ||
| 6 | + android:background="@drawable/radius_solid_white_stroke_999" | ||
| 7 | + android:gravity="center_horizontal" | ||
| 8 | + android:orientation="vertical" | ||
| 9 | + android:paddingBottom="@dimen/ui_DIMEN_20.0PX" | ||
| 10 | + xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 11 | +<EditText | ||
| 12 | + android:id="@+id/dialog_edt_username" | ||
| 13 | + style="@style/home_login_edit_style" | ||
| 14 | + android:hint="用户名"/> | ||
| 15 | + <EditText | ||
| 16 | + android:id="@+id/dialog_edt_userpwd" | ||
| 17 | + style="@style/home_login_edit_style" | ||
| 18 | + android:hint="密码"/> | ||
| 19 | + <Button | ||
| 20 | + android:id="@+id/dialog_btn_enter" | ||
| 21 | + android:layout_width="100dp" | ||
| 22 | + android:layout_height="wrap_content" | ||
| 23 | + style="@style/home_site_btn_style" | ||
| 24 | + android:text="登录" | ||
| 25 | + /> | ||
| 26 | +</LinearLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:id="@+id/ll_chat_fragment_parent" | ||
| 4 | + android:layout_width="match_parent" | ||
| 5 | + android:layout_height="match_parent" | ||
| 6 | + android:background="#ebebeb" | ||
| 7 | + android:orientation="vertical"> | ||
| 8 | + | ||
| 9 | + <com.mang.xuedianyun.android.widget.chat.KJChatKeyboard | ||
| 10 | + android:id="@+id/chat_msg_input_box" | ||
| 11 | + android:layout_width="match_parent" | ||
| 12 | + android:layout_height="wrap_content" | ||
| 13 | + android:layout_alignParentBottom="true" /> | ||
| 14 | + | ||
| 15 | + <ListView | ||
| 16 | + android:id="@+id/chat_listview" | ||
| 17 | + android:layout_width="match_parent" | ||
| 18 | + android:layout_height="match_parent" | ||
| 19 | + android:layout_above="@+id/chat_msg_input_box" | ||
| 20 | + android:cacheColorHint="#00000000" | ||
| 21 | + android:divider="@null" | ||
| 22 | + android:dividerHeight="8.33dp" | ||
| 23 | + android:scrollbarStyle="outsideOverlay" | ||
| 24 | + android:transcriptMode="normal" /> | ||
| 25 | + | ||
| 26 | + <View | ||
| 27 | + android:id="@+id/view_line" | ||
| 28 | + android:layout_width="match_parent" | ||
| 29 | + android:layout_height="1dp" | ||
| 30 | + android:layout_below="@id/chat_listview" | ||
| 31 | + android:background="#7fd8d8d8" /> | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + <!-- --> | ||
| 35 | + | ||
| 36 | +</RelativeLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:orientation="vertical" android:layout_width="match_parent" | ||
| 4 | + android:layout_height="match_parent"> | ||
| 5 | + <com.mang.xuedianyun.android.widget.CanvasView | ||
| 6 | + android:id="@+id/canvas_doc_show" | ||
| 7 | + android:layout_width="wrap_content" | ||
| 8 | + android:layout_height="wrap_content" /> | ||
| 9 | +</RelativeLayout> |
| 1 | +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="match_parent" | ||
| 5 | + tools:context="com.mang.xuedianyun.android.fragment.PublishFragment"> | ||
| 6 | + | ||
| 7 | + <!-- TODO: Update blank fragment layout --> | ||
| 8 | + <SurfaceView | ||
| 9 | + android:id="@+id/sur_publish" | ||
| 10 | + android:layout_width="match_parent" | ||
| 11 | + android:layout_height="200dp" | ||
| 12 | + android:text="@string/hello_blank_fragment" /> | ||
| 13 | + <Button | ||
| 14 | + android:id="@+id/btn_publish_gets" | ||
| 15 | + android:layout_width="wrap_content" | ||
| 16 | + android:layout_height="wrap_content" | ||
| 17 | + android:text="获取推流地址,开始推流" | ||
| 18 | + /> | ||
| 19 | + <Button | ||
| 20 | + android:id="@+id/btn_publish_stop" | ||
| 21 | + android:layout_width="wrap_content" | ||
| 22 | + android:layout_height="wrap_content" | ||
| 23 | + android:text="停止推流" | ||
| 24 | + /> | ||
| 25 | +</FrameLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="160dp" | ||
| 5 | + android:orientation="vertical"> | ||
| 6 | + | ||
| 7 | + <android.support.v4.view.ViewPager | ||
| 8 | + android:id="@+id/frag_pager_face" | ||
| 9 | + android:layout_width="match_parent" | ||
| 10 | + android:layout_height="150dp"> | ||
| 11 | + </android.support.v4.view.ViewPager> | ||
| 12 | + | ||
| 13 | + <RadioGroup | ||
| 14 | + android:id="@+id/frag_point" | ||
| 15 | + android:layout_width="match_parent" | ||
| 16 | + android:layout_height="10dp" | ||
| 17 | + android:layout_marginBottom="6dip" | ||
| 18 | + android:background="#00000000" | ||
| 19 | + android:gravity="center" | ||
| 20 | + android:orientation="horizontal"> | ||
| 21 | + </RadioGroup> | ||
| 22 | + | ||
| 23 | +</LinearLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<com.mang.xuedianyun.android.widget.emoji.EmoticonsTextView | ||
| 3 | + android:id="@+id/itemEmoji" | ||
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 5 | + android:layout_width="33dp" | ||
| 6 | + android:layout_height="33dp" | ||
| 7 | + android:layout_margin="2dp" | ||
| 8 | + android:adjustViewBounds="true" | ||
| 9 | + android:background="@android:color/transparent" | ||
| 10 | + android:gravity="center" | ||
| 11 | + android:textColor="@android:color/black" | ||
| 12 | + android:textSize="25sp"/> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="55dp" | ||
| 4 | + android:layout_height="55dp" | ||
| 5 | + android:gravity="center" | ||
| 6 | + android:padding="5dip"> | ||
| 7 | + | ||
| 8 | + <ImageView | ||
| 9 | + android:id="@+id/itemImage" | ||
| 10 | + android:layout_width="45dp" | ||
| 11 | + android:layout_height="45dp" | ||
| 12 | + android:layout_centerInParent="true" | ||
| 13 | + android:adjustViewBounds="true" | ||
| 14 | + android:contentDescription="@null" | ||
| 15 | + android:scaleType="centerCrop"/> | ||
| 16 | + | ||
| 17 | +</RelativeLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:my="http://schemas.android.com/apk/res-auto" | ||
| 4 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | + android:layout_width="match_parent" | ||
| 6 | + android:layout_height="wrap_content" | ||
| 7 | + android:orientation="vertical" | ||
| 8 | + android:paddingLeft="@dimen/ui_DIMEN_24.0PX" | ||
| 9 | + android:paddingRight="@dimen/ui_DIMEN_24.0PX"> | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + <TextView | ||
| 13 | + android:id="@+id/chat_item_date" | ||
| 14 | + android:layout_width="@dimen/ui_DIMEN_80.0PX" | ||
| 15 | + android:layout_height="@dimen/ui_DIMEN_35.0PX" | ||
| 16 | + android:layout_gravity="center_horizontal" | ||
| 17 | + android:background="@drawable/home_chat_item_date_bg" | ||
| 18 | + android:gravity="center" | ||
| 19 | + android:textColor="#ffffff" | ||
| 20 | + android:textSize="@dimen/ui_DIMEN_22.0PX" | ||
| 21 | + android:visibility="gone" /> | ||
| 22 | + | ||
| 23 | + <RelativeLayout | ||
| 24 | + android:layout_width="match_parent" | ||
| 25 | + android:layout_height="wrap_content" | ||
| 26 | + android:layout_marginLeft="5dp" | ||
| 27 | + android:layout_marginTop="5dp"> | ||
| 28 | + | ||
| 29 | + <ImageView | ||
| 30 | + | ||
| 31 | + android:id="@+id/chat_item_avatar" | ||
| 32 | + style="@style/home_chat_item_avatar" | ||
| 33 | + android:layout_alignParentLeft="true" /> | ||
| 34 | + | ||
| 35 | + <LinearLayout | ||
| 36 | + android:id="@+id/ll_item_name_parent" | ||
| 37 | + android:layout_width="wrap_content" | ||
| 38 | + android:layout_height="wrap_content" | ||
| 39 | + android:layout_marginLeft="@dimen/ui_DIMEN_20.0PX" | ||
| 40 | + android:layout_toRightOf="@id/chat_item_avatar" | ||
| 41 | + android:orientation="horizontal"> | ||
| 42 | + | ||
| 43 | + <TextView | ||
| 44 | + android:id="@+id/chat_item_taacher_bg" | ||
| 45 | + android:layout_width="wrap_content" | ||
| 46 | + android:layout_height="wrap_content" | ||
| 47 | + android:layout_marginRight="@dimen/ui_DIMEN_8.0PX" | ||
| 48 | + android:background="@drawable/home_chat_teacher_bg" | ||
| 49 | + android:gravity="center" | ||
| 50 | + android:paddingLeft="@dimen/ui_DIMEN_10.0PX" | ||
| 51 | + android:paddingRight="@dimen/ui_DIMEN_10.0PX" | ||
| 52 | + android:text="老师" | ||
| 53 | + android:textColor="#ffffff" | ||
| 54 | + android:textSize="@dimen/ui_DIMEN_20.0PX" | ||
| 55 | + android:visibility="gone" /> | ||
| 56 | + | ||
| 57 | + <TextView | ||
| 58 | + android:id="@+id/chat_item_name" | ||
| 59 | + android:layout_width="wrap_content" | ||
| 60 | + android:layout_height="wrap_content" | ||
| 61 | + android:text="" | ||
| 62 | + android:textColor="#808080" | ||
| 63 | + android:textSize="@dimen/ui_DIMEN_22.0PX" /> | ||
| 64 | + </LinearLayout> | ||
| 65 | + | ||
| 66 | + | ||
| 67 | + <RelativeLayout | ||
| 68 | + android:id="@+id/chat_item_layout_content" | ||
| 69 | + style="@style/home_chat_item_content" | ||
| 70 | + android:layout_below="@id/ll_item_name_parent" | ||
| 71 | + android:layout_centerVertical="true" | ||
| 72 | + android:layout_marginTop="@dimen/ui_DIMEN_8.0PX" | ||
| 73 | + android:layout_toRightOf="@id/chat_item_avatar"> | ||
| 74 | + | ||
| 75 | + <com.mang.xuedianyun.android.widget.emoji.EmoticonsTextView | ||
| 76 | + android:id="@+id/chat_item_content_text" | ||
| 77 | + style="@style/home_chat_item_text_content" | ||
| 78 | + android:layout_centerInParent="true" | ||
| 79 | + android:background="@drawable/chat_pop_receive" | ||
| 80 | + android:gravity="start|center_vertical" | ||
| 81 | + android:paddingLeft="@dimen/ui_DIMEN_20.0PX" | ||
| 82 | + android:paddingRight="@dimen/ui_DIMEN_10.0PX" | ||
| 83 | + my:emojiconSize="@dimen/ui_DIMEN_40.0PX" | ||
| 84 | + tools:text="" /> | ||
| 85 | + | ||
| 86 | + <ImageView | ||
| 87 | + android:id="@+id/chat_item_content_image" | ||
| 88 | + style="@style/home_chat_item_image_content" | ||
| 89 | + android:visibility="gone" /> | ||
| 90 | + </RelativeLayout> | ||
| 91 | + | ||
| 92 | + <ImageView | ||
| 93 | + android:id="@+id/chat_item_fail" | ||
| 94 | + android:layout_width="25dp" | ||
| 95 | + android:layout_height="25dp" | ||
| 96 | + android:layout_centerVertical="true" | ||
| 97 | + android:layout_toRightOf="@+id/chat_item_layout_content" | ||
| 98 | + android:background="@mipmap/msg_state_fail_resend" | ||
| 99 | + android:focusable="false" | ||
| 100 | + android:visibility="gone" /> | ||
| 101 | + | ||
| 102 | + <ProgressBar | ||
| 103 | + android:id="@+id/chat_item_progress" | ||
| 104 | + style="@android:style/Widget.ProgressBar.Small.Inverse" | ||
| 105 | + android:layout_width="wrap_content" | ||
| 106 | + android:layout_height="wrap_content" | ||
| 107 | + android:layout_centerVertical="true" | ||
| 108 | + android:layout_toRightOf="@+id/chat_item_layout_content" | ||
| 109 | + android:visibility="gone" /> | ||
| 110 | + </RelativeLayout> | ||
| 111 | + | ||
| 112 | +</LinearLayout> |
| @@ -67,7 +67,7 @@ | @@ -67,7 +67,7 @@ | ||
| 67 | android:layout_toLeftOf="@id/chat_item_avatar" | 67 | android:layout_toLeftOf="@id/chat_item_avatar" |
| 68 | android:gravity="end"> | 68 | android:gravity="end"> |
| 69 | 69 | ||
| 70 | - <com.mang.xdy.demo.widget.emoji.EmoticonsTextView | 70 | + <com.mang.xuedianyun.android.widget.emoji.EmoticonsTextView |
| 71 | android:id="@+id/chat_item_content_text" | 71 | android:id="@+id/chat_item_content_text" |
| 72 | style="@style/home_chat_item_text_content" | 72 | style="@style/home_chat_item_text_content" |
| 73 | android:layout_centerVertical="true" | 73 | android:layout_centerVertical="true" |
| @@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
| 33 | android:visibility="gone" | 33 | android:visibility="gone" |
| 34 | android:button="@null"/> | 34 | android:button="@null"/> |
| 35 | 35 | ||
| 36 | - <com.mang.xdy.demo.widget.emoji.EmoticonsEditText | 36 | + <com.mang.xuedianyun.android.widget.emoji.EmoticonsEditText |
| 37 | android:id="@+id/toolbox_et_message" | 37 | android:id="@+id/toolbox_et_message" |
| 38 | android:layout_width="match_parent" | 38 | android:layout_width="match_parent" |
| 39 | android:layout_height="wrap_content" | 39 | android:layout_height="wrap_content" |
| @@ -78,7 +78,7 @@ | @@ -78,7 +78,7 @@ | ||
| 78 | android:layout_width="match_parent" | 78 | android:layout_width="match_parent" |
| 79 | android:layout_height="160dp"></android.support.v4.view.ViewPager> | 79 | android:layout_height="160dp"></android.support.v4.view.ViewPager> |
| 80 | 80 | ||
| 81 | - <com.mang.xdy.demo.widget.chat.PagerSlidingTabStrip | 81 | + <com.mang.xuedianyun.android.widget.chat.PagerSlidingTabStrip |
| 82 | android:id="@+id/toolbox_tabs" | 82 | android:id="@+id/toolbox_tabs" |
| 83 | android:layout_width="match_parent" | 83 | android:layout_width="match_parent" |
| 84 | android:layout_height="40dp" | 84 | android:layout_height="40dp" |
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
| 6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
| 7 | android:orientation="vertical" | 7 | android:orientation="vertical" |
| 8 | - tools:context="com.mang.xdy.demo.MainActivity"> | 8 | + tools:context="com.mang.xuedianyun.android.MainActivity"> |
| 9 | <RelativeLayout | 9 | <RelativeLayout |
| 10 | android:id="@+id/rl_home_close" | 10 | android:id="@+id/rl_home_close" |
| 11 | android:layout_width="@dimen/ui_DIMEN_98.0PX" | 11 | android:layout_width="@dimen/ui_DIMEN_98.0PX" |
| @@ -44,7 +44,7 @@ | @@ -44,7 +44,7 @@ | ||
| 44 | style="@style/home_input_edit_style" | 44 | style="@style/home_input_edit_style" |
| 45 | android:hint="classId" | 45 | android:hint="classId" |
| 46 | android:inputType="number" | 46 | android:inputType="number" |
| 47 | - android:text="118417229"/> | 47 | + android:text="1992614331"/> |
| 48 | 48 | ||
| 49 | <View | 49 | <View |
| 50 | style="@style/ui_divider_line_horizontal" | 50 | style="@style/ui_divider_line_horizontal" |
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | android:layout_width="match_parent" | 6 | android:layout_width="match_parent" |
| 7 | android:layout_height="match_parent" | 7 | android:layout_height="match_parent" |
| 8 | android:orientation="vertical" | 8 | android:orientation="vertical" |
| 9 | - tools:context="com.mang.xdy.demo.activity.VideoPlayActivity"> | 9 | + tools:context="com.mang.xuedianyun.android.activity.VideoPlayActivity"> |
| 10 | <RelativeLayout | 10 | <RelativeLayout |
| 11 | android:id="@+id/rel_videoPlay_play" | 11 | android:id="@+id/rel_videoPlay_play" |
| 12 | android:layout_width="match_parent" | 12 | android:layout_width="match_parent" |
| @@ -21,13 +21,12 @@ | @@ -21,13 +21,12 @@ | ||
| 21 | android:layout_width="match_parent" | 21 | android:layout_width="match_parent" |
| 22 | android:layout_height="match_parent" | 22 | android:layout_height="match_parent" |
| 23 | /> | 23 | /> |
| 24 | - android:layout_width="match_parent" | ||
| 25 | - android:layout_height="match_parent"> | ||
| 26 | <ImageView | 24 | <ImageView |
| 27 | android:id="@+id/img_playVideo_novideo" | 25 | android:id="@+id/img_playVideo_novideo" |
| 28 | android:layout_width="match_parent" | 26 | android:layout_width="match_parent" |
| 29 | android:layout_height="match_parent" | 27 | android:layout_height="match_parent" |
| 30 | - android:background="@mipmap/novideo" | 28 | + android:scaleType="fitXY" |
| 29 | + android:background="@mipmap/no_video" | ||
| 31 | /> | 30 | /> |
| 32 | <FrameLayout | 31 | <FrameLayout |
| 33 | android:layout_width="match_parent" | 32 | android:layout_width="match_parent" |
| @@ -59,6 +58,12 @@ | @@ -59,6 +58,12 @@ | ||
| 59 | android:layout_alignParentTop="true" | 58 | android:layout_alignParentTop="true" |
| 60 | android:paddingLeft="@dimen/ui_DIMEN_20.0PX" | 59 | android:paddingLeft="@dimen/ui_DIMEN_20.0PX" |
| 61 | android:paddingRight="@dimen/ui_DIMEN_20.0PX"> | 60 | android:paddingRight="@dimen/ui_DIMEN_20.0PX"> |
| 61 | + <LinearLayout | ||
| 62 | + android:id="@+id/ll_videoPlay_back" | ||
| 63 | + android:layout_width="wrap_content" | ||
| 64 | + android:layout_height="wrap_content" | ||
| 65 | + android:orientation="horizontal" | ||
| 66 | + > | ||
| 62 | 67 | ||
| 63 | <ImageView | 68 | <ImageView |
| 64 | android:id="@+id/img_videoPlay_back" | 69 | android:id="@+id/img_videoPlay_back" |
| @@ -76,6 +81,7 @@ | @@ -76,6 +81,7 @@ | ||
| 76 | android:gravity="center" | 81 | android:gravity="center" |
| 77 | android:textColor="@color/white" | 82 | android:textColor="@color/white" |
| 78 | /> | 83 | /> |
| 84 | + </LinearLayout> | ||
| 79 | <TextView | 85 | <TextView |
| 80 | android:id="@+id/tv_videoPlay_className" | 86 | android:id="@+id/tv_videoPlay_className" |
| 81 | style="@style/ui_wrapTvBaseStyle" | 87 | style="@style/ui_wrapTvBaseStyle" |
| @@ -95,6 +101,13 @@ | @@ -95,6 +101,13 @@ | ||
| 95 | android:layout_alignParentRight="true" | 101 | android:layout_alignParentRight="true" |
| 96 | android:layout_alignParentBottom="true" | 102 | android:layout_alignParentBottom="true" |
| 97 | /> | 103 | /> |
| 104 | + <com.pili.pldroid.player.widget.PLVideoTextureView | ||
| 105 | + android:id="@+id/img_playVideo_pushreplay" | ||
| 106 | + android:layout_width="120dp" | ||
| 107 | + android:layout_height="150dp" | ||
| 108 | + android:layout_alignParentBottom="true" | ||
| 109 | + android:layout_alignParentRight="true" | ||
| 110 | + /> | ||
| 98 | <ImageView | 111 | <ImageView |
| 99 | android:id="@+id/img_playVideo_publishAudio" | 112 | android:id="@+id/img_playVideo_publishAudio" |
| 100 | android:layout_width="150dp" | 113 | android:layout_width="150dp" |
| @@ -164,7 +177,7 @@ | @@ -164,7 +177,7 @@ | ||
| 164 | custom:tl_textUnselectColor="@color/home_tab_unselected" | 177 | custom:tl_textUnselectColor="@color/home_tab_unselected" |
| 165 | 178 | ||
| 166 | custom:tl_textsize="@dimen/ui_DIMEN_28.0PX"/> | 179 | custom:tl_textsize="@dimen/ui_DIMEN_28.0PX"/> |
| 167 | - <com.mang.xdy.demo.widget.view.NoScrollViewPager | 180 | + <com.mang.xuedianyun.android.widget.view.NoScrollViewPager |
| 168 | android:id="@+id/viewpager" | 181 | android:id="@+id/viewpager" |
| 169 | android:layout_below="@+id/stl_videoPlay_tab" | 182 | android:layout_below="@+id/stl_videoPlay_tab" |
| 170 | android:layout_width="match_parent" | 183 | android:layout_width="match_parent" |
| @@ -172,7 +185,7 @@ | @@ -172,7 +185,7 @@ | ||
| 172 | android:layout_weight="1" | 185 | android:layout_weight="1" |
| 173 | android:background="@android:color/white" > | 186 | android:background="@android:color/white" > |
| 174 | 187 | ||
| 175 | - </com.mang.xdy.demo.widget.view.NoScrollViewPager> | 188 | + </com.mang.xuedianyun.android.widget.view.NoScrollViewPager> |
| 176 | 189 | ||
| 177 | 190 | ||
| 178 | <FrameLayout | 191 | <FrameLayout |
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
| 6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
| 7 | android:orientation="vertical" | 7 | android:orientation="vertical" |
| 8 | - tools:context="com.mang.xdy.demo.activity.VideoPlayActivity"> | 8 | + tools:context="com.mang.xuedianyun.android.activity.VideoPlayActivity"> |
| 9 | <RelativeLayout | 9 | <RelativeLayout |
| 10 | android:layout_width="wrap_content" | 10 | android:layout_width="wrap_content" |
| 11 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" |
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | android:background="#ebebeb" | 6 | android:background="#ebebeb" |
| 7 | android:orientation="vertical"> | 7 | android:orientation="vertical"> |
| 8 | 8 | ||
| 9 | - <com.mang.xdy.demo.widget.chat.KJChatKeyboard | 9 | + <com.mang.xuedianyun.android.widget.chat.KJChatKeyboard |
| 10 | android:id="@+id/chat_msg_input_box" | 10 | android:id="@+id/chat_msg_input_box" |
| 11 | android:layout_width="match_parent" | 11 | android:layout_width="match_parent" |
| 12 | android:layout_height="wrap_content" | 12 | android:layout_height="wrap_content" |
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | android:orientation="vertical" android:layout_width="match_parent" | 3 | android:orientation="vertical" android:layout_width="match_parent" |
| 4 | android:layout_height="match_parent"> | 4 | android:layout_height="match_parent"> |
| 5 | - <com.mang.xdy.demo.widget.CanvasView | 5 | + <com.mang.xuedianyun.android.widget.CanvasView |
| 6 | android:id="@+id/canvas_doc_show" | 6 | android:id="@+id/canvas_doc_show" |
| 7 | android:layout_width="wrap_content" | 7 | android:layout_width="wrap_content" |
| 8 | android:layout_height="wrap_content" /> | 8 | android:layout_height="wrap_content" /> |
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | xmlns:tools="http://schemas.android.com/tools" | 2 | xmlns:tools="http://schemas.android.com/tools" |
| 3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
| 4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
| 5 | - tools:context="com.mang.xdy.demo.fragment.PublishFragment"> | 5 | + tools:context="com.mang.xuedianyun.android.fragment.PublishFragment"> |
| 6 | 6 | ||
| 7 | <!-- TODO: Update blank fragment layout --> | 7 | <!-- TODO: Update blank fragment layout --> |
| 8 | <SurfaceView | 8 | <SurfaceView |
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | -<com.mang.xdy.demo.widget.emoji.EmoticonsTextView | 2 | +<com.mang.xuedianyun.android.widget.emoji.EmoticonsTextView |
| 3 | android:id="@+id/itemEmoji" | 3 | android:id="@+id/itemEmoji" |
| 4 | xmlns:android="http://schemas.android.com/apk/res/android" | 4 | xmlns:android="http://schemas.android.com/apk/res/android" |
| 5 | android:layout_width="33dp" | 5 | android:layout_width="33dp" |
| @@ -72,7 +72,7 @@ | @@ -72,7 +72,7 @@ | ||
| 72 | android:layout_marginTop="@dimen/ui_DIMEN_8.0PX" | 72 | android:layout_marginTop="@dimen/ui_DIMEN_8.0PX" |
| 73 | android:layout_toRightOf="@id/chat_item_avatar"> | 73 | android:layout_toRightOf="@id/chat_item_avatar"> |
| 74 | 74 | ||
| 75 | - <com.mang.xdy.demo.widget.emoji.EmoticonsTextView | 75 | + <com.mang.xuedianyun.android.widget.emoji.EmoticonsTextView |
| 76 | android:id="@+id/chat_item_content_text" | 76 | android:id="@+id/chat_item_content_text" |
| 77 | style="@style/home_chat_item_text_content" | 77 | style="@style/home_chat_item_text_content" |
| 78 | android:layout_centerInParent="true" | 78 | android:layout_centerInParent="true" |
| @@ -67,7 +67,7 @@ | @@ -67,7 +67,7 @@ | ||
| 67 | android:layout_toLeftOf="@id/chat_item_avatar" | 67 | android:layout_toLeftOf="@id/chat_item_avatar" |
| 68 | android:gravity="end"> | 68 | android:gravity="end"> |
| 69 | 69 | ||
| 70 | - <com.mang.xdy.demo.widget.emoji.EmoticonsTextView | 70 | + <com.mang.xuedianyun.android.widget.emoji.EmoticonsTextView |
| 71 | android:id="@+id/chat_item_content_text" | 71 | android:id="@+id/chat_item_content_text" |
| 72 | style="@style/home_chat_item_text_content" | 72 | style="@style/home_chat_item_text_content" |
| 73 | android:layout_centerVertical="true" | 73 | android:layout_centerVertical="true" |
| @@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
| 33 | android:visibility="gone" | 33 | android:visibility="gone" |
| 34 | android:button="@null"/> | 34 | android:button="@null"/> |
| 35 | 35 | ||
| 36 | - <com.mang.xdy.demo.widget.emoji.EmoticonsEditText | 36 | + <com.mang.xuedianyun.android.widget.emoji.EmoticonsEditText |
| 37 | android:id="@+id/toolbox_et_message" | 37 | android:id="@+id/toolbox_et_message" |
| 38 | android:layout_width="match_parent" | 38 | android:layout_width="match_parent" |
| 39 | android:layout_height="wrap_content" | 39 | android:layout_height="wrap_content" |
| @@ -78,7 +78,7 @@ | @@ -78,7 +78,7 @@ | ||
| 78 | android:layout_width="match_parent" | 78 | android:layout_width="match_parent" |
| 79 | android:layout_height="160dp"></android.support.v4.view.ViewPager> | 79 | android:layout_height="160dp"></android.support.v4.view.ViewPager> |
| 80 | 80 | ||
| 81 | - <com.mang.xdy.demo.widget.chat.PagerSlidingTabStrip | 81 | + <com.mang.xuedianyun.android.widget.chat.PagerSlidingTabStrip |
| 82 | android:id="@+id/toolbox_tabs" | 82 | android:id="@+id/toolbox_tabs" |
| 83 | android:layout_width="match_parent" | 83 | android:layout_width="match_parent" |
| 84 | android:layout_height="40dp" | 84 | android:layout_height="40dp" |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:tool="http://schemas.android.com/tools" | ||
| 4 | + | ||
| 5 | + android:layout_width="match_parent" | ||
| 6 | + tool:visibility="visible" | ||
| 7 | + android:layout_height="match_parent" | ||
| 8 | + android:orientation="vertical" | ||
| 9 | + > | ||
| 10 | + <LinearLayout | ||
| 11 | + android:id="@+id/ll_exam_spreadOrfold" | ||
| 12 | + android:layout_width="60dp" | ||
| 13 | + android:layout_height="60dp" | ||
| 14 | + android:layout_marginBottom="-20dp" | ||
| 15 | + android:layout_gravity="right" | ||
| 16 | + android:visibility="gone" | ||
| 17 | + android:orientation="vertical"> | ||
| 18 | + | ||
| 19 | + </LinearLayout> | ||
| 20 | + <CheckBox | ||
| 21 | + android:id="@+id/cb_exam_spreadOrfold" | ||
| 22 | + android:layout_width="45dp" | ||
| 23 | + android:layout_height="45dp" | ||
| 24 | + android:layout_marginBottom="-17dp" | ||
| 25 | + android:layout_gravity="right" | ||
| 26 | + android:button="@null" | ||
| 27 | + android:drawableRight="@drawable/selector_exam_fold"/> | ||
| 28 | + <!--<CheckBox--> | ||
| 29 | + <!--android:id="@+id/cb_exam_A"--> | ||
| 30 | + <!--style="@style/exam_cb_style_SingleOrMore"--> | ||
| 31 | + <!--android:drawableLeft="@drawable/selector_exam"--> | ||
| 32 | + <!--android:text="A" />--> | ||
| 33 | + <!--倒计时--> | ||
| 34 | + <RelativeLayout | ||
| 35 | + android:layout_width="match_parent" | ||
| 36 | + android:background="#e3e3e3" | ||
| 37 | + android:id="@+id/rel_exam_layout" | ||
| 38 | + android:layout_height="90dp"> | ||
| 39 | + <RelativeLayout | ||
| 40 | + android:id="@+id/rel_home_tv_exam_countdown" | ||
| 41 | + android:layout_width="wrap_content" | ||
| 42 | + android:layout_height="match_parent" | ||
| 43 | + android:orientation="vertical"> | ||
| 44 | + <TextView | ||
| 45 | + android:id="@+id/tv_exam_countdown" | ||
| 46 | + android:layout_width="23dp" | ||
| 47 | + android:layout_height="15dp" | ||
| 48 | + android:layout_marginRight="5dp" | ||
| 49 | + android:layout_alignParentLeft="true" | ||
| 50 | + android:text="__s" | ||
| 51 | + android:textSize="12dp" | ||
| 52 | + android:textColor="@color/actionsheet_red" | ||
| 53 | + android:background="@color/white" | ||
| 54 | + /> | ||
| 55 | + </RelativeLayout> | ||
| 56 | + <RelativeLayout | ||
| 57 | + android:layout_marginLeft="5dp" | ||
| 58 | + android:layout_toRightOf="@+id/rel_home_tv_exam_countdown" | ||
| 59 | + android:layout_width="match_parent" | ||
| 60 | + android:layout_height="match_parent" | ||
| 61 | + > | ||
| 62 | + <!--单选多选--> | ||
| 63 | + <LinearLayout | ||
| 64 | + android:id="@+id/ll_exam_SingleOrMore" | ||
| 65 | + android:layout_width="match_parent" | ||
| 66 | + android:layout_height="match_parent" | ||
| 67 | + android:layout_toLeftOf="@+id/ll_exam_submit" | ||
| 68 | + android:gravity="center" | ||
| 69 | + android:visibility="gone" | ||
| 70 | + android:orientation="horizontal" | ||
| 71 | + > | ||
| 72 | + <CheckBox | ||
| 73 | + android:id="@+id/cb_exam_A" | ||
| 74 | + style="@style/exam_cb_style_SingleOrMore" | ||
| 75 | + android:drawableLeft="@drawable/selector_exam" | ||
| 76 | + android:text="A" /> | ||
| 77 | + | ||
| 78 | + <CheckBox | ||
| 79 | + android:id="@+id/cb_exam_B" | ||
| 80 | + style="@style/exam_cb_style_SingleOrMore" | ||
| 81 | + android:drawableLeft="@drawable/selector_exam" | ||
| 82 | + android:text="B" /> | ||
| 83 | + | ||
| 84 | + <CheckBox | ||
| 85 | + android:id="@+id/cb_exam_C" | ||
| 86 | + style="@style/exam_cb_style_SingleOrMore" | ||
| 87 | + android:drawableLeft="@drawable/selector_exam" | ||
| 88 | + android:text="C" /> | ||
| 89 | + | ||
| 90 | + <CheckBox | ||
| 91 | + android:id="@+id/cb_exam_D" | ||
| 92 | + style="@style/exam_cb_style_SingleOrMore" | ||
| 93 | + android:drawableLeft="@drawable/selector_exam" | ||
| 94 | + android:text="D" /> | ||
| 95 | + </LinearLayout> | ||
| 96 | + <!--对错--> | ||
| 97 | + <LinearLayout | ||
| 98 | + android:id="@+id/ll_exam_selectRightOrWrong" | ||
| 99 | + android:layout_width="match_parent" | ||
| 100 | + android:layout_height="match_parent" | ||
| 101 | + android:layout_toLeftOf="@+id/ll_exam_submit" | ||
| 102 | + android:gravity="center" | ||
| 103 | + android:visibility="gone" | ||
| 104 | + tool:visibility="visible" | ||
| 105 | + android:orientation="horizontal" | ||
| 106 | + > | ||
| 107 | + <RadioGroup | ||
| 108 | + android:layout_width="match_parent" | ||
| 109 | + android:layout_height="match_parent" | ||
| 110 | + android:orientation="horizontal" | ||
| 111 | + > | ||
| 112 | + <RadioButton | ||
| 113 | + android:id="@+id/rb_exam_R" | ||
| 114 | + style="@style/exam_cb_style_RightOrWrong" | ||
| 115 | + android:drawableLeft="@drawable/selector_exam" | ||
| 116 | + android:checked="true" | ||
| 117 | + android:text="对" /> | ||
| 118 | + | ||
| 119 | + <RadioButton | ||
| 120 | + android:id="@+id/rb_exam_W" | ||
| 121 | + style="@style/exam_cb_style_RightOrWrong" | ||
| 122 | + android:drawableLeft="@drawable/selector_exam" | ||
| 123 | + android:text="错" /> | ||
| 124 | + </RadioGroup> | ||
| 125 | + </LinearLayout> | ||
| 126 | + | ||
| 127 | + <LinearLayout | ||
| 128 | + android:id="@+id/ll_exam_filling" | ||
| 129 | + android:layout_width="match_parent" | ||
| 130 | + android:layout_height="match_parent" | ||
| 131 | + android:layout_toLeftOf="@+id/ll_exam_submit" | ||
| 132 | + android:gravity="center" | ||
| 133 | + android:visibility="gone" | ||
| 134 | + android:orientation="horizontal" | ||
| 135 | + > | ||
| 136 | + <TextView | ||
| 137 | + android:layout_width="wrap_content" | ||
| 138 | + android:layout_height="wrap_content" | ||
| 139 | + android:layout_weight="1" | ||
| 140 | + android:hint="一" | ||
| 141 | + /> | ||
| 142 | + <TextView | ||
| 143 | + android:layout_width="wrap_content" | ||
| 144 | + android:layout_height="wrap_content" | ||
| 145 | + android:layout_weight="1" | ||
| 146 | + android:hint="二" | ||
| 147 | + /> | ||
| 148 | + | ||
| 149 | + <EditText | ||
| 150 | + android:layout_width="20dp" | ||
| 151 | + android:layout_height="wrap_content" | ||
| 152 | + android:layout_weight="1" | ||
| 153 | + android:maxLength="20" | ||
| 154 | + android:singleLine="true" | ||
| 155 | + android:hint="输入答案" | ||
| 156 | + /> | ||
| 157 | + </LinearLayout> | ||
| 158 | + | ||
| 159 | + | ||
| 160 | + <!--答案--> | ||
| 161 | + <LinearLayout | ||
| 162 | + android:id="@+id/ll_exam_answer" | ||
| 163 | + android:layout_width="match_parent" | ||
| 164 | + android:layout_height="match_parent" | ||
| 165 | + android:layout_toLeftOf="@+id/ll_exam_submit" | ||
| 166 | + android:gravity="center|left" | ||
| 167 | + android:visibility="gone" | ||
| 168 | + tool:visibility="visible" | ||
| 169 | + android:orientation="vertical" | ||
| 170 | + > | ||
| 171 | + <LinearLayout | ||
| 172 | + android:layout_width="wrap_content" | ||
| 173 | + android:layout_height="wrap_content" | ||
| 174 | + android:orientation="horizontal"> | ||
| 175 | + <TextView | ||
| 176 | + android:layout_width="wrap_content" | ||
| 177 | + android:layout_height="wrap_content" | ||
| 178 | + android:text="我的答案:" | ||
| 179 | + /> | ||
| 180 | + | ||
| 181 | + <LinearLayout | ||
| 182 | + android:id="@+id/ll_exam_Myanswer" | ||
| 183 | + android:layout_width="wrap_content" | ||
| 184 | + android:layout_height="wrap_content" | ||
| 185 | + android:gravity="center" | ||
| 186 | + android:orientation="horizontal"> | ||
| 187 | + </LinearLayout> | ||
| 188 | + </LinearLayout> | ||
| 189 | + <LinearLayout | ||
| 190 | + android:layout_width="match_parent" | ||
| 191 | + android:layout_height="wrap_content" | ||
| 192 | + android:layout_marginTop="5dp" | ||
| 193 | + android:orientation="horizontal"> | ||
| 194 | + <TextView | ||
| 195 | + android:layout_width="wrap_content" | ||
| 196 | + android:layout_height="wrap_content" | ||
| 197 | + android:text="正确答案:" | ||
| 198 | + /> | ||
| 199 | + <TextView | ||
| 200 | + android:layout_width="wrap_content" | ||
| 201 | + android:layout_height="wrap_content" | ||
| 202 | + android:layout_centerInParent="true" | ||
| 203 | + android:layout_margin="4dp" | ||
| 204 | + android:background="@mipmap/lv_bj" | ||
| 205 | + android:gravity="center" | ||
| 206 | + android:textColor="@android:color/white" | ||
| 207 | + android:text="C" | ||
| 208 | + android:visibility="gone" | ||
| 209 | + /> | ||
| 210 | + <LinearLayout | ||
| 211 | + android:id="@+id/ll_exam_Correctanswer" | ||
| 212 | + android:layout_width="wrap_content" | ||
| 213 | + android:layout_height="wrap_content" | ||
| 214 | + android:gravity="center" | ||
| 215 | + android:orientation="horizontal"> | ||
| 216 | + </LinearLayout> | ||
| 217 | + | ||
| 218 | + <TextView | ||
| 219 | + android:layout_width="wrap_content" | ||
| 220 | + android:layout_height="wrap_content" | ||
| 221 | + android:layout_marginLeft="10dp" | ||
| 222 | + android:text="正确率:" | ||
| 223 | + /> | ||
| 224 | + <TextView | ||
| 225 | + android:layout_width="wrap_content" | ||
| 226 | + android:layout_height="wrap_content" | ||
| 227 | + android:text="20%" | ||
| 228 | + /> | ||
| 229 | + </LinearLayout> | ||
| 230 | + | ||
| 231 | + </LinearLayout> | ||
| 232 | + <!--提交--> | ||
| 233 | + <LinearLayout | ||
| 234 | + android:id="@+id/ll_exam_submit" | ||
| 235 | + android:layout_width="100dp" | ||
| 236 | + android:layout_height="match_parent" | ||
| 237 | + android:orientation="horizontal" | ||
| 238 | + android:gravity="center" | ||
| 239 | + android:layout_marginLeft="10dp" | ||
| 240 | + android:layout_alignParentRight="true" | ||
| 241 | + > | ||
| 242 | + <TextView | ||
| 243 | + android:id="@+id/tv_exam_up" | ||
| 244 | + android:layout_width="wrap_content" | ||
| 245 | + android:layout_height="wrap_content" | ||
| 246 | + | ||
| 247 | + android:text="提交" | ||
| 248 | + android:layout_gravity="center_vertical" | ||
| 249 | + android:textColor="@android:color/white" | ||
| 250 | + android:background="@drawable/shape_bg_full_circle_blue" | ||
| 251 | + android:layout_marginRight="10dp" | ||
| 252 | + android:textSize="12sp" | ||
| 253 | + /> | ||
| 254 | + <TextView | ||
| 255 | + android:id="@+id/tv_exam_cancle" | ||
| 256 | + android:layout_width="wrap_content" | ||
| 257 | + android:layout_height="wrap_content" | ||
| 258 | + android:text="放弃" | ||
| 259 | + android:layout_gravity="center_vertical" | ||
| 260 | + android:textColor="@android:color/white" | ||
| 261 | + android:background="@drawable/shape_bg_full_circle_grey" | ||
| 262 | + android:layout_marginRight="8dp" | ||
| 263 | + android:textSize="12sp" | ||
| 264 | + /> | ||
| 265 | + </LinearLayout> | ||
| 266 | + </RelativeLayout> | ||
| 267 | + </RelativeLayout> | ||
| 268 | + </LinearLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:orientation="vertical" android:layout_width="match_parent" | ||
| 4 | + android:background="#e3e3e3" | ||
| 5 | + android:layout_height="match_parent"> | ||
| 6 | + <TextView | ||
| 7 | + android:layout_width="match_parent" | ||
| 8 | + android:text="wo jiusldjflkdjf" | ||
| 9 | + android:layout_height="wrap_content" /> | ||
| 10 | +</LinearLayout> |
2.3 KB
12.4 KB
2.2 KB
2.7 KB
| @@ -30,6 +30,8 @@ | @@ -30,6 +30,8 @@ | ||
| 30 | <string name="home_title_back">Back</string> | 30 | <string name="home_title_back">Back</string> |
| 31 | <string name="home_msg_play_audio_init">Audio playback initialization</string> | 31 | <string name="home_msg_play_audio_init">Audio playback initialization</string> |
| 32 | <string name="home_msg_play_video_init">Video playback initialization</string> | 32 | <string name="home_msg_play_video_init">Video playback initialization</string> |
| 33 | + | ||
| 34 | + <string name="imge_load_error">Pictures for failure</string> | ||
| 33 | <!--登录--> | 35 | <!--登录--> |
| 34 | <string name="main_login_error_classId">Please enter class number</string> | 36 | <string name="main_login_error_classId">Please enter class number</string> |
| 35 | <string name="main_login_error_portal">Please enter portal</string> | 37 | <string name="main_login_error_portal">Please enter portal</string> |
| @@ -30,6 +30,8 @@ | @@ -30,6 +30,8 @@ | ||
| 30 | <string name="home_title_back">返回</string> | 30 | <string name="home_title_back">返回</string> |
| 31 | <string name="home_msg_play_audio_init">音频播放初始化</string> | 31 | <string name="home_msg_play_audio_init">音频播放初始化</string> |
| 32 | <string name="home_msg_play_video_init">视频播放初始化</string> | 32 | <string name="home_msg_play_video_init">视频播放初始化</string> |
| 33 | + | ||
| 34 | + <string name="imge_load_error">图片获取失败</string> | ||
| 33 | <!--登录--> | 35 | <!--登录--> |
| 34 | <string name="main_login_error_classId">课堂Id不能为空</string> | 36 | <string name="main_login_error_classId">课堂Id不能为空</string> |
| 35 | <string name="main_login_error_portal">服务器地址不能为空</string> | 37 | <string name="main_login_error_portal">服务器地址不能为空</string> |
| 1 | -/* | ||
| 2 | - * SmartPlayer.java | ||
| 3 | - * SmartPlayer | ||
| 4 | - * | ||
| 5 | - * Github: https://github.com/daniulive/SmarterStreaming | ||
| 6 | - * WebSite: http://www.daniulive.com | ||
| 7 | - * | ||
| 8 | - * Created by DaniuLive on 2015/09/26. | ||
| 9 | - * Copyright © 2014~2017 DaniuLive. All rights reserved. | ||
| 10 | - */ | ||
| 11 | - | ||
| 12 | -package com.daniulive.smartplayer; | ||
| 13 | - | ||
| 14 | -import java.nio.ByteBuffer; | ||
| 15 | - | ||
| 16 | -import android.app.Activity; | ||
| 17 | -import android.app.AlertDialog; | ||
| 18 | -import android.content.Context; | ||
| 19 | -import android.content.DialogInterface; | ||
| 20 | -import android.content.res.Configuration; | ||
| 21 | -import android.os.Bundle; | ||
| 22 | -import android.util.Log; | ||
| 23 | -import android.view.SurfaceView; | ||
| 24 | - | ||
| 25 | -import android.view.View; | ||
| 26 | -import android.view.ViewGroup.LayoutParams; | ||
| 27 | -import android.widget.Button; | ||
| 28 | -import android.widget.EditText; | ||
| 29 | -import android.widget.FrameLayout; | ||
| 30 | -import android.widget.LinearLayout; | ||
| 31 | -import android.widget.RelativeLayout; | ||
| 32 | -import android.widget.TextView; | ||
| 33 | - | ||
| 34 | -import com.eventhandle.SmartEventCallback; | ||
| 35 | -import com.videoengine.*; | ||
| 36 | - | ||
| 37 | -public class SmartPlayer extends Activity { | ||
| 38 | - | ||
| 39 | - private SurfaceView sSurfaceView = null; | ||
| 40 | - | ||
| 41 | - private long playerHandle = 0; | ||
| 42 | - | ||
| 43 | - private static final int PORTRAIT = 1; //竖屏 | ||
| 44 | - private static final int LANDSCAPE = 2; //横屏 | ||
| 45 | - private static final String TAG = "SmartPlayer"; | ||
| 46 | - | ||
| 47 | - private SmartPlayerJni libPlayer = null; | ||
| 48 | - | ||
| 49 | - private int currentOrigentation = PORTRAIT; | ||
| 50 | - | ||
| 51 | - private boolean isPlaybackViewStarted = false; | ||
| 52 | - | ||
| 53 | - private String playbackUrl = null; | ||
| 54 | - | ||
| 55 | - private boolean isMute = false; | ||
| 56 | - | ||
| 57 | - private boolean isHardwareDecoder = false; | ||
| 58 | - | ||
| 59 | - Button btnPopInputText; | ||
| 60 | - Button btnPopInputUrl; | ||
| 61 | - Button btnMute; | ||
| 62 | - Button btnStartStopPlayback; | ||
| 63 | - Button btnHardwareDecoder; | ||
| 64 | - TextView txtCopyright; | ||
| 65 | - TextView txtQQQun; | ||
| 66 | - | ||
| 67 | - LinearLayout lLayout = null; | ||
| 68 | - FrameLayout fFrameLayout = null; | ||
| 69 | - | ||
| 70 | - private Context myContext; | ||
| 71 | - String url="rtmp://player.daniulive.com:1935/hls/stream"; | ||
| 72 | - static { | ||
| 73 | - System.loadLibrary("SmartPlayer"); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - @Override protected void onCreate(Bundle icicle) { | ||
| 77 | - super.onCreate(icicle); | ||
| 78 | - url=getIntent().getStringExtra("url"); | ||
| 79 | - Log.i(TAG, "Run into OnCreate++"); | ||
| 80 | - Log.e("URl",url+""); | ||
| 81 | - libPlayer = new SmartPlayerJni(); | ||
| 82 | - | ||
| 83 | - myContext = this.getApplicationContext(); | ||
| 84 | - | ||
| 85 | - boolean bViewCreated = CreateView(); | ||
| 86 | - | ||
| 87 | - if(bViewCreated){ | ||
| 88 | - inflateLayout(LinearLayout.VERTICAL); | ||
| 89 | - } | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - /* For smartplayer demo app, the url is based on: baseURL + inputID | ||
| 93 | - * For example: | ||
| 94 | - * baseURL: rtmp://player.daniulive.com:1935/hls/stream | ||
| 95 | - * inputID: 123456 | ||
| 96 | - * playbackUrl: rtmp://player.daniulive.com:1935/hls/stream123456 | ||
| 97 | - * */ | ||
| 98 | - private void GenerateURL(String id){ | ||
| 99 | - if(id == null) | ||
| 100 | - return; | ||
| 101 | - | ||
| 102 | - if(id.equals("hks")) | ||
| 103 | - { | ||
| 104 | - playbackUrl = "rtmp://live.hkstv.hk.lxdns.com/live/hks"; | ||
| 105 | - return; | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - btnStartStopPlayback.setEnabled(true); | ||
| 109 | -// String baseURL = "rtmp://player.daniulive.com:1935/hls/stream"; | ||
| 110 | - String baseURL = url; | ||
| 111 | - | ||
| 112 | - playbackUrl = baseURL + id; | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - private void SaveInputUrl(String url) | ||
| 116 | - { | ||
| 117 | - playbackUrl = ""; | ||
| 118 | - | ||
| 119 | - if ( url == null ) | ||
| 120 | - return; | ||
| 121 | - | ||
| 122 | - // rtmp:/ | ||
| 123 | - if ( url.length() < 8 ) | ||
| 124 | - { | ||
| 125 | - Log.e(TAG, "Input full url error:" + url); | ||
| 126 | - return; | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - if ( !url.startsWith("rtmp://") && !url.startsWith("rtsp://")) | ||
| 130 | - { | ||
| 131 | - Log.e(TAG, "Input full url error:" + url); | ||
| 132 | - return; | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - btnStartStopPlayback.setEnabled(true); | ||
| 136 | - playbackUrl = url; | ||
| 137 | - | ||
| 138 | - Log.i(TAG, "Input full url:" + url); | ||
| 139 | - } | ||
| 140 | - | ||
| 141 | - /* Popup InputID dialog */ | ||
| 142 | - private void PopDialog(){ | ||
| 143 | - final EditText inputID = new EditText(this); | ||
| 144 | - inputID.setFocusable(true); | ||
| 145 | - | ||
| 146 | - AlertDialog.Builder builder = new AlertDialog.Builder(this); | ||
| 147 | - builder.setTitle("如 rtmp://player.daniulive.com:1935/hls/stream123456,请输入123456").setView(inputID).setNegativeButton( | ||
| 148 | - "取消", null); | ||
| 149 | - builder.setPositiveButton("确认", new DialogInterface.OnClickListener() { | ||
| 150 | - | ||
| 151 | - public void onClick(DialogInterface dialog, int which) { | ||
| 152 | -// String strID = inputID.getText().toString() ; | ||
| 153 | - String strID = url; | ||
| 154 | - GenerateURL(strID); | ||
| 155 | - } | ||
| 156 | - }); | ||
| 157 | - builder.show(); | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | - | ||
| 161 | - private void PopFullUrlDialog(){ | ||
| 162 | - final EditText inputUrlTxt = new EditText(this); | ||
| 163 | - inputUrlTxt.setFocusable(true); | ||
| 164 | - inputUrlTxt.setText(url+""); | ||
| 165 | - | ||
| 166 | - AlertDialog.Builder builderUrl = new AlertDialog.Builder(this); | ||
| 167 | - builderUrl.setTitle(""+url).setView(inputUrlTxt).setNegativeButton( | ||
| 168 | - "取消", null); | ||
| 169 | - builderUrl.setPositiveButton("确认", new DialogInterface.OnClickListener() { | ||
| 170 | - | ||
| 171 | - public void onClick(DialogInterface dialog, int which) { | ||
| 172 | - //TODO 这个位置是修改的 | ||
| 173 | - String fullUrl =url; | ||
| 174 | -// String fullUrl = inputUrlTxt.getText().toString(); | ||
| 175 | - SaveInputUrl(fullUrl); | ||
| 176 | - } | ||
| 177 | - }); | ||
| 178 | - builderUrl.show(); | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - /* Generate basic layout */ | ||
| 182 | - private void inflateLayout(int orientation) { | ||
| 183 | - if (null == lLayout) | ||
| 184 | - lLayout = new LinearLayout(this); | ||
| 185 | - | ||
| 186 | - addContentView(lLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, | ||
| 187 | - LayoutParams.WRAP_CONTENT)); | ||
| 188 | - | ||
| 189 | - lLayout.setOrientation(orientation); | ||
| 190 | - | ||
| 191 | - fFrameLayout = new FrameLayout(this); | ||
| 192 | - | ||
| 193 | - LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT, 1.0f); | ||
| 194 | - fFrameLayout.setLayoutParams(lp); | ||
| 195 | - Log.i(TAG, "++inflateLayout.."); | ||
| 196 | - | ||
| 197 | - sSurfaceView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); | ||
| 198 | - | ||
| 199 | - fFrameLayout.addView(sSurfaceView, 0); | ||
| 200 | - | ||
| 201 | - RelativeLayout outLinearLayout = new RelativeLayout(this); | ||
| 202 | - outLinearLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT)); | ||
| 203 | - | ||
| 204 | - LinearLayout lLinearLayout = new LinearLayout(this); | ||
| 205 | - lLinearLayout.setOrientation(LinearLayout.VERTICAL); | ||
| 206 | - lLinearLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); | ||
| 207 | - | ||
| 208 | - | ||
| 209 | - LinearLayout copyRightLinearLayout = new LinearLayout(this); | ||
| 210 | - copyRightLinearLayout.setOrientation(LinearLayout.VERTICAL); | ||
| 211 | - RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); | ||
| 212 | - rl.topMargin = getWindowManager().getDefaultDisplay().getHeight()-270; | ||
| 213 | - copyRightLinearLayout.setLayoutParams(rl); | ||
| 214 | - | ||
| 215 | - txtCopyright=new TextView(this); | ||
| 216 | - txtCopyright.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); | ||
| 217 | - txtCopyright.setText("Copyright 2014~2016 www.daniulive.com v1.0.16.0326"); | ||
| 218 | - copyRightLinearLayout.addView(txtCopyright, 0); | ||
| 219 | - | ||
| 220 | - txtQQQun=new TextView(this); | ||
| 221 | - txtQQQun.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); | ||
| 222 | - txtQQQun.setText("学点云"); | ||
| 223 | - copyRightLinearLayout.addView(txtQQQun, 1); | ||
| 224 | - | ||
| 225 | - /* PopInput button */ | ||
| 226 | - btnPopInputText = new Button(this); | ||
| 227 | - btnPopInputText.setText("输入urlID"); | ||
| 228 | - btnPopInputText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); | ||
| 229 | - lLinearLayout.addView(btnPopInputText, 0); | ||
| 230 | - | ||
| 231 | - btnPopInputUrl = new Button(this); | ||
| 232 | - btnPopInputUrl.setText("输入完整url"); | ||
| 233 | - btnPopInputUrl.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); | ||
| 234 | - lLinearLayout.addView(btnPopInputUrl, 1); | ||
| 235 | - | ||
| 236 | - /*mute button */ | ||
| 237 | - isMute = false; | ||
| 238 | - btnMute = new Button(this); | ||
| 239 | - btnMute.setText("静音 "); | ||
| 240 | - btnMute.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); | ||
| 241 | - lLinearLayout.addView(btnMute, 2); | ||
| 242 | - | ||
| 243 | - /*hardware decoder button */ | ||
| 244 | - isHardwareDecoder = false; | ||
| 245 | - btnHardwareDecoder = new Button(this); | ||
| 246 | - btnHardwareDecoder.setText("当前软解码"); | ||
| 247 | - btnHardwareDecoder.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); | ||
| 248 | - lLinearLayout.addView(btnHardwareDecoder, 3); | ||
| 249 | - | ||
| 250 | - /* Start playback stream button */ | ||
| 251 | - btnStartStopPlayback = new Button(this); | ||
| 252 | - btnStartStopPlayback.setText("开始播放 "); | ||
| 253 | - btnStartStopPlayback.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); | ||
| 254 | - lLinearLayout.addView(btnStartStopPlayback, 4); | ||
| 255 | - | ||
| 256 | - | ||
| 257 | - outLinearLayout.addView(lLinearLayout, 0); | ||
| 258 | - outLinearLayout.addView(copyRightLinearLayout, 1); | ||
| 259 | - fFrameLayout.addView(outLinearLayout, 1); | ||
| 260 | - | ||
| 261 | - lLayout.addView(fFrameLayout, 0); | ||
| 262 | - | ||
| 263 | - if(isPlaybackViewStarted) | ||
| 264 | - { | ||
| 265 | - btnPopInputText.setEnabled(false); | ||
| 266 | - btnPopInputUrl.setEnabled(false); | ||
| 267 | - btnHardwareDecoder.setEnabled(false); | ||
| 268 | - btnStartStopPlayback.setText("停止播放 "); | ||
| 269 | - } | ||
| 270 | - else | ||
| 271 | - { | ||
| 272 | - btnPopInputText.setEnabled(true); | ||
| 273 | - btnPopInputUrl.setEnabled(true); | ||
| 274 | - btnHardwareDecoder.setEnabled(true); | ||
| 275 | - btnStartStopPlayback.setText("开始播放 "); | ||
| 276 | - } | ||
| 277 | - | ||
| 278 | - /* PopInput button listener */ | ||
| 279 | - btnPopInputText.setOnClickListener(new Button.OnClickListener() { | ||
| 280 | - | ||
| 281 | - // @Override | ||
| 282 | - public void onClick(View v) { | ||
| 283 | - Log.i(TAG, "Run into input playback ID++"); | ||
| 284 | - | ||
| 285 | - PopDialog(); | ||
| 286 | - | ||
| 287 | - Log.i(TAG, "Run out from input playback ID--"); | ||
| 288 | - } | ||
| 289 | - }); | ||
| 290 | - | ||
| 291 | - | ||
| 292 | - btnPopInputUrl.setOnClickListener(new Button.OnClickListener() { | ||
| 293 | - public void onClick(View v) { | ||
| 294 | - PopFullUrlDialog(); | ||
| 295 | - } | ||
| 296 | - }); | ||
| 297 | - | ||
| 298 | - btnMute.setOnClickListener(new Button.OnClickListener() | ||
| 299 | - { | ||
| 300 | - public void onClick(View v) { | ||
| 301 | - isMute = !isMute; | ||
| 302 | - | ||
| 303 | - if ( isMute ) | ||
| 304 | - { | ||
| 305 | - btnMute.setText("取消静音"); | ||
| 306 | - } | ||
| 307 | - else | ||
| 308 | - { | ||
| 309 | - btnMute.setText("静音"); | ||
| 310 | - } | ||
| 311 | - | ||
| 312 | - if ( playerHandle != 0 ) | ||
| 313 | - { | ||
| 314 | - libPlayer.SmartPlayerSetMute(playerHandle, isMute?1:0); | ||
| 315 | - } | ||
| 316 | - } | ||
| 317 | - }); | ||
| 318 | - | ||
| 319 | - btnHardwareDecoder.setOnClickListener(new Button.OnClickListener() | ||
| 320 | - { | ||
| 321 | - public void onClick(View v) { | ||
| 322 | - isHardwareDecoder = !isHardwareDecoder; | ||
| 323 | - | ||
| 324 | - if ( isHardwareDecoder ) | ||
| 325 | - { | ||
| 326 | - btnHardwareDecoder.setText("当前硬解码"); | ||
| 327 | - } | ||
| 328 | - else | ||
| 329 | - { | ||
| 330 | - btnHardwareDecoder.setText("当前软解码"); | ||
| 331 | - } | ||
| 332 | - | ||
| 333 | - } | ||
| 334 | - }); | ||
| 335 | - | ||
| 336 | - btnStartStopPlayback.setOnClickListener(new Button.OnClickListener() { | ||
| 337 | - | ||
| 338 | - // @Override | ||
| 339 | - public void onClick(View v) { | ||
| 340 | - | ||
| 341 | - if(isPlaybackViewStarted) | ||
| 342 | - { | ||
| 343 | - Log.i(TAG, "Stop playback stream++"); | ||
| 344 | - btnStartStopPlayback.setText("开始播放 "); | ||
| 345 | - btnPopInputText.setEnabled(true); | ||
| 346 | - btnPopInputUrl.setEnabled(true); | ||
| 347 | - btnHardwareDecoder.setEnabled(true); | ||
| 348 | - libPlayer.SmartPlayerClose(playerHandle); | ||
| 349 | - playerHandle = 0; | ||
| 350 | - isPlaybackViewStarted = false; | ||
| 351 | - Log.i(TAG, "Stop playback stream--"); | ||
| 352 | - } | ||
| 353 | - else | ||
| 354 | - { | ||
| 355 | - Log.i(TAG, "Start playback stream++"); | ||
| 356 | - | ||
| 357 | - playerHandle = libPlayer.SmartPlayerInit(myContext); | ||
| 358 | - | ||
| 359 | - if(playerHandle == 0) | ||
| 360 | - { | ||
| 361 | - Log.e(TAG, "surfaceHandle with nil.."); | ||
| 362 | - return; | ||
| 363 | - } | ||
| 364 | - | ||
| 365 | - libPlayer.SetSmartPlayerEventCallback(playerHandle, new EventHande()); | ||
| 366 | - | ||
| 367 | - libPlayer.SmartPlayerSetSurface(playerHandle, sSurfaceView); //if set the second param with null, it means it will playback audio only.. | ||
| 368 | - | ||
| 369 | - // libPlayer.SmartPlayerSetSurface(playerHandle, null); | ||
| 370 | - | ||
| 371 | - // External Render test | ||
| 372 | - //libPlayer.SmartPlayerSetExternalRender(playerHandle, new RGBAExternalRender()); | ||
| 373 | - //libPlayer.SmartPlayerSetExternalRender(playerHandle, new I420ExternalRender()); | ||
| 374 | - | ||
| 375 | - libPlayer.SmartPlayerSetAudioOutputType(playerHandle, 0); | ||
| 376 | - | ||
| 377 | - libPlayer.SmartPlayerSetBuffer(playerHandle, 200); | ||
| 378 | - | ||
| 379 | - if ( isMute ) | ||
| 380 | - { | ||
| 381 | - libPlayer.SmartPlayerSetMute(playerHandle, isMute?1:0); | ||
| 382 | - } | ||
| 383 | - | ||
| 384 | - if( isHardwareDecoder ) | ||
| 385 | - { | ||
| 386 | - Log.i(TAG, "check isHardwareDecoder: " + isHardwareDecoder); | ||
| 387 | - | ||
| 388 | - int hwChecking = libPlayer.SetSmartPlayerVideoHWDecoder(playerHandle, isHardwareDecoder?1:0); | ||
| 389 | - | ||
| 390 | - Log.i(TAG, "[daniulive] hwChecking: " + hwChecking); | ||
| 391 | - } | ||
| 392 | - | ||
| 393 | - //It only used when playback RTSP stream.. | ||
| 394 | - // libPlayer.SmartPlayerSetRTSPTcpMode(playerHandle, 1); | ||
| 395 | - | ||
| 396 | - //playbackUrl = "rtmp://live.hkstv.hk.lxdns.com/live/hks"; | ||
| 397 | - | ||
| 398 | - //playbackUrl = "rtsp://rtsp-v3-spbtv.msk.spbtv.com/spbtv_v3_1/214_110.sdp"; | ||
| 399 | - | ||
| 400 | - //playbackUrl = "rtmp://10.2.68.91:1935/hls/stream8"; | ||
| 401 | - | ||
| 402 | - if(playbackUrl == null){ | ||
| 403 | - Log.e(TAG, "playback URL with NULL..."); | ||
| 404 | - return; | ||
| 405 | - } | ||
| 406 | - | ||
| 407 | - int iPlaybackRet = libPlayer.SmartPlayerStartPlayback(playerHandle, playbackUrl); | ||
| 408 | - | ||
| 409 | - if(iPlaybackRet != 0) | ||
| 410 | - { | ||
| 411 | - Log.e(TAG, "StartPlayback strem failed.."); | ||
| 412 | - return; | ||
| 413 | - } | ||
| 414 | - | ||
| 415 | - btnStartStopPlayback.setText("停止播放 "); | ||
| 416 | - btnPopInputText.setEnabled(false); | ||
| 417 | - btnPopInputUrl.setEnabled(false); | ||
| 418 | - btnHardwareDecoder.setEnabled(false); | ||
| 419 | - isPlaybackViewStarted = true; | ||
| 420 | - Log.i(TAG, "Start playback stream--"); | ||
| 421 | - } | ||
| 422 | - } | ||
| 423 | - }); | ||
| 424 | - } | ||
| 425 | - | ||
| 426 | - | ||
| 427 | - public static final String bytesToHexString(byte[] buffer) | ||
| 428 | - { | ||
| 429 | - StringBuffer sb = new StringBuffer(buffer.length); | ||
| 430 | - String temp; | ||
| 431 | - | ||
| 432 | - for (int i = 0; i < buffer.length; ++i) | ||
| 433 | - { | ||
| 434 | - temp = Integer.toHexString(0xff&buffer[i]); | ||
| 435 | - if (temp.length() < 2) | ||
| 436 | - sb.append(0); | ||
| 437 | - | ||
| 438 | - sb.append(temp); | ||
| 439 | - } | ||
| 440 | - | ||
| 441 | - return sb.toString(); | ||
| 442 | - } | ||
| 443 | - | ||
| 444 | - class RGBAExternalRender implements NTExternalRender | ||
| 445 | - { | ||
| 446 | - //public static final int NT_FRAME_FORMAT_RGBA = 1; | ||
| 447 | - //public static final int NT_FRAME_FORMAT_ABGR = 2; | ||
| 448 | - //public static final int NT_FRAME_FORMAT_I420 = 3; | ||
| 449 | - | ||
| 450 | - private int width_ = 0; | ||
| 451 | - private int height_ = 0; | ||
| 452 | - private int row_bytes_ = 0; | ||
| 453 | - private ByteBuffer rgba_buffer_ = null; | ||
| 454 | - | ||
| 455 | - @Override | ||
| 456 | - public int getNTFrameFormat() | ||
| 457 | - { | ||
| 458 | - Log.i(TAG, "RGBAExternalRender::getNTFrameFormat return "+ NT_FRAME_FORMAT_RGBA); | ||
| 459 | - return NT_FRAME_FORMAT_RGBA; | ||
| 460 | - } | ||
| 461 | - | ||
| 462 | - @Override | ||
| 463 | - public void onNTFrameSizeChanged(int width, int height) | ||
| 464 | - { | ||
| 465 | - width_ = width; | ||
| 466 | - height_ = height; | ||
| 467 | - | ||
| 468 | - row_bytes_ = width_ * 4; | ||
| 469 | - | ||
| 470 | - Log.i(TAG, "RGBAExternalRender::onNTFrameSizeChanged width_:" + width_ + " height_:" + height_); | ||
| 471 | - | ||
| 472 | - rgba_buffer_ = ByteBuffer.allocateDirect(row_bytes_*height_); | ||
| 473 | - } | ||
| 474 | - | ||
| 475 | - @Override | ||
| 476 | - public ByteBuffer getNTPlaneByteBuffer(int index) | ||
| 477 | - { | ||
| 478 | - if ( index == 0 ) | ||
| 479 | - { | ||
| 480 | - return rgba_buffer_; | ||
| 481 | - } | ||
| 482 | - else | ||
| 483 | - { | ||
| 484 | - Log.e(TAG, "RGBAExternalRender::getNTPlaneByteBuffer index error:" + index); | ||
| 485 | - return null; | ||
| 486 | - } | ||
| 487 | - } | ||
| 488 | - | ||
| 489 | - @Override | ||
| 490 | - public int getNTPlanePerRowBytes(int index) | ||
| 491 | - { | ||
| 492 | - if ( index == 0 ) | ||
| 493 | - { | ||
| 494 | - return row_bytes_; | ||
| 495 | - } | ||
| 496 | - else | ||
| 497 | - { | ||
| 498 | - Log.e(TAG, "RGBAExternalRender::getNTPlanePerRowBytes index error:" + index); | ||
| 499 | - return 0; | ||
| 500 | - } | ||
| 501 | - } | ||
| 502 | - | ||
| 503 | - public void onNTRenderFrame() | ||
| 504 | - { | ||
| 505 | - if( rgba_buffer_ == null ) | ||
| 506 | - return; | ||
| 507 | - | ||
| 508 | - rgba_buffer_.rewind(); | ||
| 509 | - | ||
| 510 | - // copy buffer | ||
| 511 | - | ||
| 512 | - // test | ||
| 513 | - // byte[] test_buffer = new byte[16]; | ||
| 514 | - // rgba_buffer_.get(test_buffer); | ||
| 515 | - | ||
| 516 | - //Log.i(TAG, "RGBAExternalRender:onNTRenderFrame rgba:" + bytesToHexString(test_buffer)); | ||
| 517 | - } | ||
| 518 | - } | ||
| 519 | - | ||
| 520 | - class I420ExternalRender implements NTExternalRender | ||
| 521 | - { | ||
| 522 | - //public static final int NT_FRAME_FORMAT_RGBA = 1; | ||
| 523 | - //public static final int NT_FRAME_FORMAT_ABGR = 2; | ||
| 524 | - //public static final int NT_FRAME_FORMAT_I420 = 3; | ||
| 525 | - | ||
| 526 | - private int width_ = 0; | ||
| 527 | - private int height_ = 0; | ||
| 528 | - | ||
| 529 | - private int y_row_bytes_ = 0; | ||
| 530 | - private int u_row_bytes_ = 0; | ||
| 531 | - private int v_row_bytes_ = 0; | ||
| 532 | - | ||
| 533 | - private ByteBuffer y_buffer_ = null; | ||
| 534 | - private ByteBuffer u_buffer_ = null; | ||
| 535 | - private ByteBuffer v_buffer_ = null; | ||
| 536 | - | ||
| 537 | - @Override | ||
| 538 | - public int getNTFrameFormat() | ||
| 539 | - { | ||
| 540 | - Log.i(TAG, "I420ExternalRender::getNTFrameFormat return "+ NT_FRAME_FORMAT_I420); | ||
| 541 | - return NT_FRAME_FORMAT_I420; | ||
| 542 | - } | ||
| 543 | - | ||
| 544 | - @Override | ||
| 545 | - public void onNTFrameSizeChanged(int width, int height) | ||
| 546 | - { | ||
| 547 | - width_ = width; | ||
| 548 | - height_ = height; | ||
| 549 | - | ||
| 550 | - y_row_bytes_ = (width_ + 15) & (~15); | ||
| 551 | - u_row_bytes_ = ((width_+1)/2 + 15) & (~15); | ||
| 552 | - v_row_bytes_ = ((width_+1)/2 + 15) & (~15); | ||
| 553 | - | ||
| 554 | - y_buffer_ = ByteBuffer.allocateDirect(y_row_bytes_*height_); | ||
| 555 | - u_buffer_ = ByteBuffer.allocateDirect(u_row_bytes_*(height_+1)/2); | ||
| 556 | - v_buffer_ = ByteBuffer.allocateDirect(v_row_bytes_*(height_+1)/2); | ||
| 557 | - | ||
| 558 | - Log.i(TAG, "I420ExternalRender::onNTFrameSizeChanged width_=" | ||
| 559 | - + width_ + " height_=" + height_ | ||
| 560 | - + " y_row_bytes_=" + y_row_bytes_ | ||
| 561 | - + " u_row_bytes_=" + u_row_bytes_ | ||
| 562 | - + " v_row_bytes_=" + v_row_bytes_); | ||
| 563 | - } | ||
| 564 | - | ||
| 565 | - @Override | ||
| 566 | - public ByteBuffer getNTPlaneByteBuffer(int index) | ||
| 567 | - { | ||
| 568 | - if ( index == 0 ) | ||
| 569 | - { | ||
| 570 | - return y_buffer_; | ||
| 571 | - } | ||
| 572 | - else if ( index == 1 ) | ||
| 573 | - { | ||
| 574 | - return u_buffer_; | ||
| 575 | - } | ||
| 576 | - else if ( index == 2 ) | ||
| 577 | - { | ||
| 578 | - return v_buffer_; | ||
| 579 | - } | ||
| 580 | - else | ||
| 581 | - { | ||
| 582 | - Log.e(TAG, "I420ExternalRender::getNTPlaneByteBuffer index error:" + index); | ||
| 583 | - return null; | ||
| 584 | - } | ||
| 585 | - } | ||
| 586 | - | ||
| 587 | - @Override | ||
| 588 | - public int getNTPlanePerRowBytes(int index) | ||
| 589 | - { | ||
| 590 | - if ( index == 0 ) | ||
| 591 | - { | ||
| 592 | - return y_row_bytes_; | ||
| 593 | - } | ||
| 594 | - else if ( index == 1) | ||
| 595 | - { | ||
| 596 | - return u_row_bytes_; | ||
| 597 | - } | ||
| 598 | - else if (index == 2 ) | ||
| 599 | - { | ||
| 600 | - return v_row_bytes_; | ||
| 601 | - } | ||
| 602 | - else | ||
| 603 | - { | ||
| 604 | - Log.e(TAG, "I420ExternalRender::getNTPlanePerRowBytes index error:" + index); | ||
| 605 | - return 0; | ||
| 606 | - } | ||
| 607 | - } | ||
| 608 | - | ||
| 609 | - public void onNTRenderFrame() | ||
| 610 | - { | ||
| 611 | - if ( y_buffer_ == null ) | ||
| 612 | - return; | ||
| 613 | - | ||
| 614 | - if ( u_buffer_ == null ) | ||
| 615 | - return; | ||
| 616 | - | ||
| 617 | - if ( v_buffer_ == null ) | ||
| 618 | - return; | ||
| 619 | - | ||
| 620 | - | ||
| 621 | - y_buffer_.rewind(); | ||
| 622 | - | ||
| 623 | - u_buffer_.rewind(); | ||
| 624 | - | ||
| 625 | - v_buffer_.rewind(); | ||
| 626 | - | ||
| 627 | - // copy buffer | ||
| 628 | - | ||
| 629 | - // test | ||
| 630 | - // byte[] test_buffer = new byte[16]; | ||
| 631 | - // y_buffer_.get(test_buffer); | ||
| 632 | - | ||
| 633 | - // Log.i(TAG, "I420ExternalRender::onNTRenderFrame y data:" + bytesToHexString(test_buffer)); | ||
| 634 | - | ||
| 635 | - // u_buffer_.get(test_buffer); | ||
| 636 | - // Log.i(TAG, "I420ExternalRender::onNTRenderFrame u data:" + bytesToHexString(test_buffer)); | ||
| 637 | - | ||
| 638 | - // v_buffer_.get(test_buffer); | ||
| 639 | - // Log.i(TAG, "I420ExternalRender::onNTRenderFrame v data:" + bytesToHexString(test_buffer)); | ||
| 640 | - } | ||
| 641 | - } | ||
| 642 | - | ||
| 643 | - | ||
| 644 | - class EventHande implements SmartEventCallback | ||
| 645 | - { | ||
| 646 | - @Override | ||
| 647 | - public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5){ | ||
| 648 | - switch (code) { | ||
| 649 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED: | ||
| 650 | - Log.i(TAG, "开始。。"); | ||
| 651 | - break; | ||
| 652 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING: | ||
| 653 | - Log.i(TAG, "连接中。。"); | ||
| 654 | - break; | ||
| 655 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTION_FAILED: | ||
| 656 | - Log.i(TAG, "连接失败。。"); | ||
| 657 | - break; | ||
| 658 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED: | ||
| 659 | - Log.i(TAG, "连接成功。。"); | ||
| 660 | - break; | ||
| 661 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED: | ||
| 662 | - Log.i(TAG, "连接断开。。"); | ||
| 663 | - break; | ||
| 664 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP: | ||
| 665 | - Log.i(TAG, "关闭。。"); | ||
| 666 | - break; | ||
| 667 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO: | ||
| 668 | - Log.i(TAG, "分辨率信息: width: " + param1 + ", height: " + param2); | ||
| 669 | - break; | ||
| 670 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED: | ||
| 671 | - Log.i(TAG, "收不到媒体数据,可能是url错误。。"); | ||
| 672 | - } | ||
| 673 | - } | ||
| 674 | - } | ||
| 675 | - | ||
| 676 | - /* Create rendering */ | ||
| 677 | - private boolean CreateView() { | ||
| 678 | - | ||
| 679 | - if(sSurfaceView == null) | ||
| 680 | - { | ||
| 681 | - /* | ||
| 682 | - * useOpenGLES2: | ||
| 683 | - * If with true: Check if system supports openGLES, if supported, it will choose openGLES. | ||
| 684 | - * If with false: it will set with default surfaceView; | ||
| 685 | - */ | ||
| 686 | - sSurfaceView = NTRenderer.CreateRenderer(this, true); | ||
| 687 | - } | ||
| 688 | - | ||
| 689 | - if(sSurfaceView == null) | ||
| 690 | - { | ||
| 691 | - Log.i(TAG, "Create render failed.."); | ||
| 692 | - return false; | ||
| 693 | - } | ||
| 694 | - | ||
| 695 | - return true; | ||
| 696 | - } | ||
| 697 | - | ||
| 698 | - @Override | ||
| 699 | - public void onConfigurationChanged(Configuration newConfig) { | ||
| 700 | - super.onConfigurationChanged(newConfig); | ||
| 701 | - | ||
| 702 | - Log.i(TAG, "Run into onConfigurationChanged++"); | ||
| 703 | - | ||
| 704 | - if (null != fFrameLayout) | ||
| 705 | - { | ||
| 706 | - fFrameLayout.removeAllViews(); | ||
| 707 | - fFrameLayout = null; | ||
| 708 | - } | ||
| 709 | - | ||
| 710 | - if (null != lLayout) | ||
| 711 | - { | ||
| 712 | - lLayout.removeAllViews(); | ||
| 713 | - lLayout = null; | ||
| 714 | - } | ||
| 715 | - | ||
| 716 | - if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) | ||
| 717 | - { | ||
| 718 | - Log.i(TAG, "onConfigurationChanged, with LANDSCAPE。。"); | ||
| 719 | - | ||
| 720 | - inflateLayout(LinearLayout.HORIZONTAL); | ||
| 721 | - | ||
| 722 | - currentOrigentation = LANDSCAPE; | ||
| 723 | - } | ||
| 724 | - else | ||
| 725 | - { | ||
| 726 | - Log.i(TAG, "onConfigurationChanged, with PORTRAIT。。"); | ||
| 727 | - | ||
| 728 | - inflateLayout(LinearLayout.VERTICAL); | ||
| 729 | - | ||
| 730 | - currentOrigentation = PORTRAIT; | ||
| 731 | - } | ||
| 732 | - | ||
| 733 | - if(!isPlaybackViewStarted) | ||
| 734 | - return; | ||
| 735 | - | ||
| 736 | - libPlayer.SmartPlayerSetOrientation(playerHandle, currentOrigentation); | ||
| 737 | - | ||
| 738 | - Log.i(TAG, "Run out of onConfigurationChanged--"); | ||
| 739 | - } | ||
| 740 | - | ||
| 741 | - @Override | ||
| 742 | - protected void onDestroy() | ||
| 743 | - { | ||
| 744 | - Log.i(TAG, "Run into activity destory++"); | ||
| 745 | - | ||
| 746 | - if(playerHandle!=0) | ||
| 747 | - { | ||
| 748 | - libPlayer.SmartPlayerClose(playerHandle); | ||
| 749 | - playerHandle = 0; | ||
| 750 | - } | ||
| 751 | - super.onDestroy(); | ||
| 752 | - finish(); | ||
| 753 | -// System.exit(0); | ||
| 754 | - } | ||
| 755 | -} |
| @@ -23,6 +23,15 @@ public class VideoPlayBean { | @@ -23,6 +23,15 @@ public class VideoPlayBean { | ||
| 23 | private String rtmpUrl; | 23 | private String rtmpUrl; |
| 24 | private String replay; | 24 | private String replay; |
| 25 | private int seek; | 25 | private int seek; |
| 26 | + private String userRole; | ||
| 27 | + | ||
| 28 | + public String getUserRole() { | ||
| 29 | + return userRole; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public void setUserRole(String userRole) { | ||
| 33 | + this.userRole = userRole; | ||
| 34 | + } | ||
| 26 | 35 | ||
| 27 | public int getMediaId() { | 36 | public int getMediaId() { |
| 28 | return mediaId; | 37 | return mediaId; |
| @@ -79,4 +88,18 @@ public class VideoPlayBean { | @@ -79,4 +88,18 @@ public class VideoPlayBean { | ||
| 79 | public void setSeek(int seek) { | 88 | public void setSeek(int seek) { |
| 80 | this.seek = seek; | 89 | this.seek = seek; |
| 81 | } | 90 | } |
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public String toString() { | ||
| 94 | + return "VideoPlayBean{" + | ||
| 95 | + "mediaId=" + mediaId + | ||
| 96 | + ", fromNodeId=" + fromNodeId + | ||
| 97 | + ", userName='" + userName + '\'' + | ||
| 98 | + ", m3u8Url='" + m3u8Url + '\'' + | ||
| 99 | + ", rtmpUrl='" + rtmpUrl + '\'' + | ||
| 100 | + ", replay='" + replay + '\'' + | ||
| 101 | + ", seek=" + seek + | ||
| 102 | + ", userRole='" + userRole + '\'' + | ||
| 103 | + '}'; | ||
| 104 | + } | ||
| 82 | } | 105 | } |
| @@ -182,6 +182,11 @@ public interface Constants { | @@ -182,6 +182,11 @@ public interface Constants { | ||
| 182 | * 开始录制回放 | 182 | * 开始录制回放 |
| 183 | */ | 183 | */ |
| 184 | String START_RECORD_PLAY_BACK="startRecordPlayback"; | 184 | String START_RECORD_PLAY_BACK="startRecordPlayback"; |
| 185 | + /** | ||
| 186 | + * 主持人角色 | ||
| 187 | + */ | ||
| 188 | + String HOST="host"; | ||
| 189 | + | ||
| 185 | String UN_PUBLISH_VIDEO="unPublishVideo"; | 190 | String UN_PUBLISH_VIDEO="unPublishVideo"; |
| 186 | /*Context为空的时候给出的提示*/ | 191 | /*Context为空的时候给出的提示*/ |
| 187 | String ERROR_CONTENT_NULL="Xdy,init context is null"; | 192 | String ERROR_CONTENT_NULL="Xdy,init context is null"; |
| @@ -7,20 +7,14 @@ package com.mang.xdy.core; | @@ -7,20 +7,14 @@ package com.mang.xdy.core; | ||
| 7 | import android.content.Context; | 7 | import android.content.Context; |
| 8 | import android.graphics.Bitmap; | 8 | import android.graphics.Bitmap; |
| 9 | import android.os.Build; | 9 | import android.os.Build; |
| 10 | -import android.text.NoCopySpan; | ||
| 11 | -import android.text.TextUtils; | ||
| 12 | import android.webkit.JavascriptInterface; | 10 | import android.webkit.JavascriptInterface; |
| 13 | import android.webkit.ValueCallback; | 11 | import android.webkit.ValueCallback; |
| 14 | import android.webkit.WebChromeClient; | 12 | import android.webkit.WebChromeClient; |
| 15 | -import android.webkit.WebResourceError; | ||
| 16 | -import android.webkit.WebResourceRequest; | ||
| 17 | import android.webkit.WebSettings; | 13 | import android.webkit.WebSettings; |
| 18 | import android.webkit.WebView; | 14 | import android.webkit.WebView; |
| 19 | import android.webkit.WebViewClient; | 15 | import android.webkit.WebViewClient; |
| 20 | 16 | ||
| 21 | -import com.mang.xdy.common.Constants; | ||
| 22 | import com.mang.xdy.utils.XdyLogUtil; | 17 | import com.mang.xdy.utils.XdyLogUtil; |
| 23 | -import com.mang.xdy.utils.XdyStringUtils; | ||
| 24 | 18 | ||
| 25 | /** | 19 | /** |
| 26 | * 数据的异常检测都放在最外层(便于给用户提示),这层默认数据都是完整 | 20 | * 数据的异常检测都放在最外层(便于给用户提示),这层默认数据都是完整 |
| @@ -125,10 +119,10 @@ public class XdyJsCore { | @@ -125,10 +119,10 @@ public class XdyJsCore { | ||
| 125 | @JavascriptInterface | 119 | @JavascriptInterface |
| 126 | public void _js2native(String id,String parmp){ | 120 | public void _js2native(String id,String parmp){ |
| 127 | /* _native2js("接口名称","参数为JOSN字符串")*/ | 121 | /* _native2js("接口名称","参数为JOSN字符串")*/ |
| 128 | - // XdyLogUtil.e("s3sjs2native","id:"+id+" parmp:"+parmp); | ||
| 129 | - if(mOnXdyAsyncMessageListener !=null){ | ||
| 130 | - mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,parmp); | ||
| 131 | - } | 122 | + XdyLogUtil.e("s3sjs2native","id:"+id+" parmp:"+parmp); |
| 123 | +// if(mOnXdyAsyncMessageListener !=null){ | ||
| 124 | +// mOnXdyAsyncMessageListener.getSdyAsyncMessageListener(id,parmp); | ||
| 125 | +// } | ||
| 132 | XdySdk.getXdyInstance().notifyObserver(id, parmp); | 126 | XdySdk.getXdyInstance().notifyObserver(id, parmp); |
| 133 | } | 127 | } |
| 134 | } | 128 | } |
| 1 | -package com.mang.xdy.core; | ||
| 2 | - | ||
| 3 | -import android.app.Activity; | ||
| 4 | -import android.content.Context; | ||
| 5 | -import android.os.Handler; | ||
| 6 | -import android.os.Message; | ||
| 7 | -import android.text.TextUtils; | ||
| 8 | -import android.util.Log; | ||
| 9 | -import android.view.SurfaceView; | ||
| 10 | - | ||
| 11 | -import com.eventhandle.SmartEventCallback; | ||
| 12 | -import com.google.gson.Gson; | ||
| 13 | -import com.mang.xdy.bean.AudioPlayBean; | ||
| 14 | -import com.mang.xdy.bean.ErrorCodeEntity; | ||
| 15 | -import com.mang.xdy.bean.GetPublishPathReceiveBean; | ||
| 16 | -import com.mang.xdy.bean.PublisherSuccessEntity; | ||
| 17 | -import com.mang.xdy.bean.PublisherVideoReturnBean; | ||
| 18 | -import com.mang.xdy.bean.VideoPlayBean; | ||
| 19 | -import com.mang.xdy.cache.ACache; | ||
| 20 | -import com.mang.xdy.common.Constants; | ||
| 21 | -import com.mang.xdy.listener.ObserverListener; | ||
| 22 | -import com.mang.xdy.listener.SubjectListener; | ||
| 23 | -import com.mang.xdy.message.MsgManage; | ||
| 24 | -import com.mang.xdy.play.XdyPlayer; | ||
| 25 | -import com.mang.xdy.play.XdyPublisher; | ||
| 26 | -import com.mang.xdy.utils.JsonUtil; | ||
| 27 | -import com.mang.xdy.utils.NetWorkUtils; | ||
| 28 | -import com.mang.xdy.utils.PlayerUtils; | ||
| 29 | -import com.mang.xdy.utils.XdyLogUtil; | ||
| 30 | -import com.mang.xdy.utils.XdyStringUtils; | ||
| 31 | - | ||
| 32 | -import org.json.JSONException; | ||
| 33 | -import org.json.JSONObject; | ||
| 34 | - | ||
| 35 | -import java.util.ArrayList; | ||
| 36 | -import java.util.List; | ||
| 37 | - | ||
| 38 | -import static com.mang.xdy.utils.PlayerUtils.getPublishPathAudio; | ||
| 39 | -import static com.mang.xdy.utils.PlayerUtils.getPublishPathVideo; | ||
| 40 | - | ||
| 41 | -/** | ||
| 42 | - * 对外调用的接口 | ||
| 43 | - * Created by abao on 2017/3/31. | ||
| 44 | - * 受原先的文档设计的规则,所有方法的都是静态的方法,影响性能 | ||
| 45 | - * 考虑跟换文档,提升性能 | ||
| 46 | - */ | ||
| 47 | -public class XdySdk implements SubjectListener{ | ||
| 48 | - /** | ||
| 49 | - * 用户初始化,还是调用各种方法,都需要统一的对外给出监听事件 | ||
| 50 | - */ | ||
| 51 | - private static XdyJsCore mXdyJsCore; | ||
| 52 | - private static XdySdk mXdySdk; | ||
| 53 | - private static Context mContext; | ||
| 54 | - private XdyPlayer mXdyPlayer; | ||
| 55 | - private XdyPublisher mXdyPublisher; | ||
| 56 | - /*消息管理*/ | ||
| 57 | - private static MsgManage mMsgManage; | ||
| 58 | - | ||
| 59 | - public static String TAG="xdysdk"; | ||
| 60 | - /*当前播放视频的id*/ | ||
| 61 | - private String currentPlayId=""; | ||
| 62 | - /*缓存管理*/ | ||
| 63 | - private static ACache aCache; | ||
| 64 | - //TODO 拿不到同步的数据先保留信息(必须释放,否者内存泄漏) | ||
| 65 | - private SurfaceView mSurfaceView_Publish; | ||
| 66 | - private Activity mActivity; | ||
| 67 | - /*是否正在推流,mcu自动断开,onPause使用的时候使用,推流成功后才表示正在使用*/ | ||
| 68 | - private boolean isPublisher =false; | ||
| 69 | -// /*Audio 推送中,resume需要使用*/ | ||
| 70 | - private boolean isPublisherAudio=false; | ||
| 71 | - /*推流重连状态,如果是重连状态会有一系列加入课堂的情况*/ | ||
| 72 | - private boolean isReconnection=false; | ||
| 73 | - /*是否进行录制回放*/ | ||
| 74 | - private boolean isRecordPlayBack=false; | ||
| 75 | - /*观察者集合*/ | ||
| 76 | - private List<ObserverListener> observerListenerList=new ArrayList<ObserverListener>(); | ||
| 77 | - /*推流地址*/ | ||
| 78 | - private String publish_url=""; | ||
| 79 | - /*保存nodeid ,自己的唯一标识*/ | ||
| 80 | - private int mNodeId =0; | ||
| 81 | - | ||
| 82 | - @Override | ||
| 83 | - public void add(ObserverListener observerListener) { | ||
| 84 | - observerListenerList.add(observerListener); | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - @Override | ||
| 88 | - public void notifyObserver(String type, String parameter) { | ||
| 89 | - handleData(type,parameter); | ||
| 90 | - XdyLogUtil.e("notifyObserVer","type:"+type+" parameter:"+parameter); | ||
| 91 | - | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - @Override | ||
| 95 | - public void remove(ObserverListener observerListener) { | ||
| 96 | - if(observerListenerList!=null){ | ||
| 97 | - if(observerListenerList.contains(observerListener)) { | ||
| 98 | - observerListenerList.remove(observerListener); | ||
| 99 | - } | ||
| 100 | - } | ||
| 101 | - } | ||
| 102 | - private XdySdk(){ | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - private static Handler handler=new Handler(){ | ||
| 106 | - @Override | ||
| 107 | - public void handleMessage(Message msg) { | ||
| 108 | - super.handleMessage(msg); | ||
| 109 | - if(msg.what==Constants.LEAVE_CLASS_CODE){ | ||
| 110 | - if(!NetWorkUtils.isNetworkConnected(mContext)) { | ||
| 111 | - if (mXdySdk != null) { | ||
| 112 | - mXdySdk.onPublisherStop(); | ||
| 113 | - handler.removeCallbacksAndMessages(null); | ||
| 114 | - } | ||
| 115 | - } | ||
| 116 | - } | ||
| 117 | - } | ||
| 118 | - }; | ||
| 119 | - /** | ||
| 120 | - * 初始化 | ||
| 121 | - * @param context | ||
| 122 | - */ | ||
| 123 | - public static void init(final Context context){ | ||
| 124 | - if(context==null){ | ||
| 125 | - throw new IllegalArgumentException(Constants.ERROR_CONTENT_NULL); | ||
| 126 | - } | ||
| 127 | - aCache=ACache.get(context); | ||
| 128 | - mContext=context; | ||
| 129 | - mXdyJsCore = XdyJsCore.getInstance(context); | ||
| 130 | - mMsgManage=MsgManage.getErrorMsgInstance(); | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - /** | ||
| 134 | - * 接收用户传递进来的参数(两个String 的参数都在这里处理) | ||
| 135 | - * @param type 类型 | ||
| 136 | - * @param argument 参数 | ||
| 137 | - */ | ||
| 138 | - public void api(final String type, final String argument){ | ||
| 139 | - judgeCore(); | ||
| 140 | - //再次停止播放器 | ||
| 141 | - switch (type){ | ||
| 142 | - case "stopPublishAudio": | ||
| 143 | - //停止推送音频 | ||
| 144 | - case "stopPublishVideo": | ||
| 145 | - //停止推流video(关闭视频:根据api) | ||
| 146 | - onPublisherStop(); | ||
| 147 | - break; | ||
| 148 | - case "stopAudio": | ||
| 149 | - //停止播放audio() | ||
| 150 | - case"stopVideo": | ||
| 151 | - //停止播放video( 停止播放:根据api) | ||
| 152 | - onPlayDestroy(); | ||
| 153 | - break; | ||
| 154 | - } | ||
| 155 | - if(!isRecordPlayBack &&!judegeNetOK()){ | ||
| 156 | - return; | ||
| 157 | - } | ||
| 158 | - handler.post(new Runnable() { | ||
| 159 | - @Override | ||
| 160 | - public void run() { | ||
| 161 | - mXdyJsCore.native2js(type, argument); | ||
| 162 | - } | ||
| 163 | - }); | ||
| 164 | - | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - /** | ||
| 168 | - * | ||
| 169 | - * @param type | ||
| 170 | - * @param | ||
| 171 | - * @param surfaceView | ||
| 172 | - * @param activity | ||
| 173 | - * @param | ||
| 174 | - * | ||
| 175 | - */ | ||
| 176 | - public void api(String type,String mediaId, SurfaceView surfaceView, Activity activity) { | ||
| 177 | - judgeString(type); | ||
| 178 | - if(!isRecordPlayBack &&!judegeNetOK()){ | ||
| 179 | - return; | ||
| 180 | - } | ||
| 181 | - switch (type) { | ||
| 182 | - case Constants.PLAY_AUDIO: | ||
| 183 | - //判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误 | ||
| 184 | - String json_audio= aCache.getAsString(mediaId); | ||
| 185 | - if(TextUtils.isEmpty(json_audio)){ | ||
| 186 | - //TODO/给出相应的提示表示没有 这个id | ||
| 187 | - XdyLogUtil.e(TAG,"Play Audio Can not find this mediaId"); | ||
| 188 | - return; | ||
| 189 | - } | ||
| 190 | - currentPlayId=mediaId; | ||
| 191 | - AudioPlayBean audioPlayBean=JsonUtil.parseJsonToBean(json_audio,AudioPlayBean.class); | ||
| 192 | - if(audioPlayBean!=null) { | ||
| 193 | - String play_url_audio=""; | ||
| 194 | - if(isRecordPlayBack){ | ||
| 195 | - //如果是回放给出。m3u8的id用户 用户需要自己获取play_url_audio=audioPlayBean.getReplay(); | ||
| 196 | - }else{ | ||
| 197 | - play_url_audio=audioPlayBean.getRtmpUrl() ; | ||
| 198 | - if(mXdyPlayer ==null) { | ||
| 199 | - mXdyPlayer = XdyPlayer.getXdyPlayerCore(play_url_audio, activity); | ||
| 200 | - }else{ | ||
| 201 | - mXdyPlayer.onStopPlay(); | ||
| 202 | - } | ||
| 203 | - mXdyPlayer.playAudio(play_url_audio, new EventHande_Play()); | ||
| 204 | - } | ||
| 205 | - | ||
| 206 | - }else{ | ||
| 207 | - XdyLogUtil.e(TAG,"Can not get play Audio response"); | ||
| 208 | - } | ||
| 209 | - break; | ||
| 210 | - case Constants.PLAY_VIDEO: | ||
| 211 | - //播放视频 | ||
| 212 | - // 判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误 | ||
| 213 | - String json_video= aCache.getAsString(mediaId); | ||
| 214 | - if(TextUtils.isEmpty(json_video)){ | ||
| 215 | - ///给出相应的提示表示没有 这个id | ||
| 216 | - XdyLogUtil.e(TAG,"Play Video Can not find this mediaId"); | ||
| 217 | - return; | ||
| 218 | - } | ||
| 219 | - currentPlayId=mediaId; | ||
| 220 | - VideoPlayBean videoPlayBean=JsonUtil.parseJsonToBean(json_video,VideoPlayBean.class); | ||
| 221 | - if(videoPlayBean!=null){ | ||
| 222 | - String play_url_video=""; | ||
| 223 | - if(isRecordPlayBack){ | ||
| 224 | -// play_url_video=videoPlayBean.getReplay(); | ||
| 225 | - }else{ | ||
| 226 | - play_url_video=videoPlayBean.getRtmpUrl(); | ||
| 227 | - if(mXdyPlayer ==null) { | ||
| 228 | - mXdyPlayer = XdyPlayer.getXdyPlayerCore(play_url_video, activity); | ||
| 229 | - }else{ | ||
| 230 | - //重复播放时候 | ||
| 231 | - mXdyPlayer.onStopPlay(); | ||
| 232 | - } | ||
| 233 | - mXdyPlayer.playVideo(play_url_video, surfaceView,new EventHande_Play()); | ||
| 234 | - } | ||
| 235 | - | ||
| 236 | - }else{ | ||
| 237 | - //统一提示推流错误 | ||
| 238 | - XdyLogUtil.e(TAG,"Can not get play Video response"); | ||
| 239 | - } | ||
| 240 | - break; | ||
| 241 | - case Constants.PUBLISH_VIDEO: | ||
| 242 | - /** | ||
| 243 | - * 用户发起这个推流的请求的时候, | ||
| 244 | - * 1,去获取推流地址 | ||
| 245 | - * 2,判断地址时候有用,有用的话打开播放器,开启推流的过程 | ||
| 246 | - * 3,推流成功告知后台,和用户 | ||
| 247 | - */ | ||
| 248 | - getPublishPathVideo(); | ||
| 249 | - mSurfaceView_Publish=surfaceView; | ||
| 250 | - mActivity=activity; | ||
| 251 | - break; | ||
| 252 | - case Constants.PUBLISH_AUDIO: | ||
| 253 | - //只推送音频 | ||
| 254 | - getPublishPathAudio(); | ||
| 255 | - mActivity=activity; | ||
| 256 | - break; | ||
| 257 | - | ||
| 258 | - } | ||
| 259 | - } | ||
| 260 | - /*判断是否被初始化*/ | ||
| 261 | - private void judgeCore(){ | ||
| 262 | - if(mXdyJsCore==null){ | ||
| 263 | - throw new IllegalArgumentException(Constants.ERROR_XDYCORE_INIT); | ||
| 264 | - } | ||
| 265 | - } | ||
| 266 | - /*判断type是否为空*/ | ||
| 267 | - private void judgeString(String type){ | ||
| 268 | - if(TextUtils.isEmpty(type)){ | ||
| 269 | - XdyLogUtil.e(TAG,Constants.ERROR_TYPE_NULL); | ||
| 270 | - } | ||
| 271 | - } | ||
| 272 | - /*判断网路是否正常*/ | ||
| 273 | - private boolean judegeNetOK(){ | ||
| 274 | - if( !NetWorkUtils.isNetworkConnected(mContext)){ | ||
| 275 | - String errorJson="{\n" + | ||
| 276 | - " \"code\": 20000,\n" + | ||
| 277 | - " \"reson\": \"无网络连接,请检查网络\"\n" + | ||
| 278 | - "}"; | ||
| 279 | - notifyObserver(Constants.ERROR_CODE, errorJson); | ||
| 280 | - return false; | ||
| 281 | - } | ||
| 282 | - return true; | ||
| 283 | - } | ||
| 284 | - | ||
| 285 | - public static XdySdk getXdyInstance(){ | ||
| 286 | - if(mXdySdk ==null){ | ||
| 287 | - synchronized (XdySdk.class){ | ||
| 288 | - mXdySdk =new XdySdk(); | ||
| 289 | - } | ||
| 290 | - } | ||
| 291 | - return mXdySdk; | ||
| 292 | - } | ||
| 293 | - /** | ||
| 294 | - *core获取到的数据处理 | ||
| 295 | - * @param type | ||
| 296 | - * @param response | ||
| 297 | - */ | ||
| 298 | - private void handleData(String type,String response){ | ||
| 299 | - //开始处理推流信息,用户只需要传递surfaceview activity, 内部处理url | ||
| 300 | - /*需要处理的信息有playVideo 返回的url地址, 遇到video_play ,和 | ||
| 301 | - audio | ||
| 302 | - plublisher Video | ||
| 303 | - publisher Audio | ||
| 304 | - | ||
| 305 | - */ | ||
| 306 | - switch (type) { | ||
| 307 | - case Constants.CLASS_JOIN_SUCCESS: | ||
| 308 | - //判断是否是录制回放,调整播流地址 | ||
| 309 | - JSONObject jsonObject = null; | ||
| 310 | - try { | ||
| 311 | - jsonObject = new JSONObject(response); | ||
| 312 | - isRecordPlayBack = jsonObject.optBoolean("isRecordPlayBack"); | ||
| 313 | - mNodeId =jsonObject.optInt("nodeId"); | ||
| 314 | - XdyLogUtil.e("获取的id",""+mNodeId); | ||
| 315 | - } catch (JSONException e) { | ||
| 316 | - e.printStackTrace(); | ||
| 317 | - } | ||
| 318 | - handleListener(type,response); | ||
| 319 | - break; | ||
| 320 | - case Constants.VIDEO_GET_PUBLISH_PATH: | ||
| 321 | - //推流地址的返回值拿到正确的推流地址直接开始推流 | ||
| 322 | - //打开推流视频 | ||
| 323 | -// String publishPath=XdyStringUtils.stringToJson(response); | ||
| 324 | - String publishPath=response; | ||
| 325 | - GetPublishPathReceiveBean getPublishPathReceiveBean=JsonUtil.parseJsonToBean(publishPath,GetPublishPathReceiveBean.class); | ||
| 326 | - if(getPublishPathReceiveBean!=null) { | ||
| 327 | - //可以推流了 | ||
| 328 | - if (getPublishPathReceiveBean.getCode() == 0) { | ||
| 329 | - //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用video_get_publish_path关键字 只支持做只支一路 | ||
| 330 | - String video_url = getPublishPathReceiveBean.getPublishUrl(); | ||
| 331 | - aCache.put(Constants.VIDEO_GET_PUBLISH_PATH, video_url); | ||
| 332 | - //判断 | ||
| 333 | - if (mSurfaceView_Publish == null) { | ||
| 334 | - //todo 输出提示 | ||
| 335 | - throw new IllegalArgumentException(Constants.ERROR_TYPE_SURFACEVIEW); | ||
| 336 | - } | ||
| 337 | - if (mActivity == null) { | ||
| 338 | - //TODo 给出提示 | ||
| 339 | - throw new IllegalArgumentException(Constants.ERROR_TYPE_ACTIVITY); | ||
| 340 | - } | ||
| 341 | - if (mXdyPublisher == null) { | ||
| 342 | - mXdyPublisher = new XdyPublisher(1, 1, mActivity); | ||
| 343 | - }else{ | ||
| 344 | - //todo 如果不为空的话是已经播放过,得清理上次的 | ||
| 345 | -// mXdyPlayer.onPause(); | ||
| 346 | - } | ||
| 347 | - publish_url=video_url; | ||
| 348 | - isPublisher =true; | ||
| 349 | - isPublisherAudio=false; | ||
| 350 | - mXdyPublisher.publisher(video_url,mSurfaceView_Publish, new EventHande_Publish()); | ||
| 351 | -// PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); | ||
| 352 | - //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断) | ||
| 353 | - setPublishSendSuccessVideo(video_url); | ||
| 354 | - }else{ | ||
| 355 | - mMsgManage.getPublishVideoPathError(); | ||
| 356 | - } | ||
| 357 | - }else{ | ||
| 358 | - //给出提示 | ||
| 359 | - //TODO | ||
| 360 | - handleListener(Constants.ERROR_CODE,"{\n" + | ||
| 361 | - " \"code\": 804,\n" + | ||
| 362 | - " \"reson\": \"推流失败\"\n" + | ||
| 363 | - "}"); | ||
| 364 | - } | ||
| 365 | - break; | ||
| 366 | - case Constants.AUDIO_GET_PUBLISH_PATH: | ||
| 367 | - //推流地址的返回值拿到正确的推流地址直接开始推流 | ||
| 368 | - //打开推流视频 | ||
| 369 | - String audio_path=response; | ||
| 370 | - GetPublishPathReceiveBean getPublishPathReceiveBean_Audio=JsonUtil.parseJsonToBean(audio_path,GetPublishPathReceiveBean.class); | ||
| 371 | - if(getPublishPathReceiveBean_Audio!=null&&getPublishPathReceiveBean_Audio.getCode()==0){ | ||
| 372 | - //可以推流了 | ||
| 373 | - String audio_url=getPublishPathReceiveBean_Audio.getPublishUrl(); | ||
| 374 | - //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用getvideopublishpath 做关键字 | ||
| 375 | - aCache.put(Constants.GET_AUDIO_PUBLISH_PATH,audio_url); | ||
| 376 | - //判断 | ||
| 377 | -// if (mSurfaceView==null){ | ||
| 378 | -// //todo 输出提示 | ||
| 379 | -// XdyLogUtil.e(TAG,"surfaceView is null"); | ||
| 380 | -// return; | ||
| 381 | -// } | ||
| 382 | - if(mActivity==null){ | ||
| 383 | - //TODo 给出提示 | ||
| 384 | - XdyLogUtil.e(TAG,"activity is null"); | ||
| 385 | - return; | ||
| 386 | - } | ||
| 387 | - if(mXdyPublisher ==null) { | ||
| 388 | - mXdyPublisher = new XdyPublisher(1, 0, mActivity); | ||
| 389 | - }else { | ||
| 390 | - //todo 如果不为空的话是已经播放过,得清理上次的 | ||
| 391 | -// mXdyPlayer.onPause(); | ||
| 392 | - } | ||
| 393 | - mXdyPublisher.publisherAudio(audio_url,new EventHande_Publish()); | ||
| 394 | - publish_url=audio_url; | ||
| 395 | - isPublisher =true; | ||
| 396 | - isPublisherAudio=true; | ||
| 397 | - //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断) | ||
| 398 | - PlayerUtils.setPublishSendSuccessAudio(audio_url); | ||
| 399 | - }else{ | ||
| 400 | - //给出提示 | ||
| 401 | - //TODO | ||
| 402 | - handleListener(Constants.ERROR_CODE,"{\n" + | ||
| 403 | - " \"code\": 804,\n" + | ||
| 404 | - " \"reson\": \"推流失败\"\n" + | ||
| 405 | - "}"); | ||
| 406 | - } | ||
| 407 | - break; | ||
| 408 | - case Constants.PUBLISH_AUDIO: | ||
| 409 | - //只推送音频 | ||
| 410 | - //接收后台是否接收到推流URl的地址 | ||
| 411 | - String publishReplay_Audio=response; | ||
| 412 | - XdyLogUtil.e(TAG,"后台成功接收到,返回值"+XdyStringUtils.stringToJson(publishReplay_Audio)); | ||
| 413 | - PublisherVideoReturnBean publisherVideoReturnBean_audio=JsonUtil.parseJsonToBean(XdyStringUtils.stringToJson(publishReplay_Audio),PublisherVideoReturnBean.class); | ||
| 414 | - if(publisherVideoReturnBean_audio!=null&&publisherVideoReturnBean_audio.getCode()==0){ | ||
| 415 | - XdyLogUtil.e(TAG,"后台成功接收到,推流的地址"); | ||
| 416 | - //TODO | ||
| 417 | - | ||
| 418 | - handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); | ||
| 419 | - }else{ | ||
| 420 | - //TODO | ||
| 421 | - handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); | ||
| 422 | - } | ||
| 423 | - break; | ||
| 424 | - case Constants.VIDEO_PUBLISH_RESULT: | ||
| 425 | - //接收发送推流地址给后台返回的信息 | ||
| 426 | - String publishReplay=response; | ||
| 427 | - XdyLogUtil.e(TAG,"后台成功接收到,返回值"+XdyStringUtils.stringToJson(publishReplay)); | ||
| 428 | - PublisherVideoReturnBean publisherVideoReturnBean=JsonUtil.parseJsonToBean(publishReplay,PublisherVideoReturnBean.class); | ||
| 429 | - if(publisherVideoReturnBean!=null&&publisherVideoReturnBean.getCode()==0){ | ||
| 430 | - XdyLogUtil.e(TAG,"后台成功接收到,推流的地址"); | ||
| 431 | - //TODO | ||
| 432 | - | ||
| 433 | - handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); | ||
| 434 | - }else{ | ||
| 435 | - //TODO | ||
| 436 | - handleListener(Constants.ERROR_CODE,"{\n" + | ||
| 437 | - " \"code\": 804,\n" + | ||
| 438 | - " \"reson\": \"推流失败\"\n" + | ||
| 439 | - "}"); | ||
| 440 | - } | ||
| 441 | - break; | ||
| 442 | - case Constants.VIDEO_PLAY: | ||
| 443 | - //获取推流的地址,需要保存起来 | ||
| 444 | - //解析数据拿出mediaId 作为主键 将media 释放的给用户可能有多个播放的情况 | ||
| 445 | - String video=response; | ||
| 446 | - VideoPlayBean videoPlayBean= JsonUtil.parseJsonToBean(video,VideoPlayBean.class); | ||
| 447 | - if(videoPlayBean!=null) { | ||
| 448 | -// if(videoPlayBean.getMediaId()!=videoPlayBean.getFromNodeId()) { | ||
| 449 | - if(mNodeId !=videoPlayBean.getFromNodeId()) { | ||
| 450 | - //过滤自己推送的video | ||
| 451 | - aCache.put(videoPlayBean.getMediaId() + "", video); | ||
| 452 | - handleListener(type, videoPlayBean.getMediaId() + ""); | ||
| 453 | - } | ||
| 454 | - }else{ | ||
| 455 | - XdyLogUtil.e(TAG,"video play json error"); | ||
| 456 | - } | ||
| 457 | - break; | ||
| 458 | - case Constants.AUDIO_PLAY: | ||
| 459 | - String audio=response; | ||
| 460 | - AudioPlayBean audioPlayBean=JsonUtil.parseJsonToBean(audio,AudioPlayBean.class); | ||
| 461 | - if(audioPlayBean!=null){ | ||
| 462 | -// if(audioPlayBean.getMediaId()!=audioPlayBean.getFromNodeId()) { | ||
| 463 | - if(mNodeId !=audioPlayBean.getFromNodeId()) { | ||
| 464 | - aCache.put(audioPlayBean.getMediaId() + "", audio); | ||
| 465 | - handleListener(type, audioPlayBean.getMediaId() + ""); | ||
| 466 | - } | ||
| 467 | - } | ||
| 468 | - break; | ||
| 469 | - case Constants.ERROR_CODE: | ||
| 470 | - ErrorCodeEntity errorCodeEntity =JsonUtil.parseJsonToBean(response,ErrorCodeEntity.class); | ||
| 471 | - if(errorCodeEntity!=null){ | ||
| 472 | - if(errorCodeEntity.getCode()==Constants.LEAVE_CLASS_CODE){ | ||
| 473 | - /** | ||
| 474 | - * 方案 一 1,正在直播的时候mcu无故断开,需要重新连接 | ||
| 475 | - * 2,class exit 时候主动课堂停止,停止推流 | ||
| 476 | - * 利用mcu的生命周期,加入课堂成功后去请求数据 | ||
| 477 | - */ | ||
| 478 | - // 方案 二 mcu 断开,页面也断开,用户需要手动重新调用 | ||
| 479 | - if(isPublisher) { | ||
| 480 | - if(!NetWorkUtils.isNetworkConnected(mContext)){ | ||
| 481 | - //todo判断是否有网络,没有网络的话就让其退出 | ||
| 482 | - // TOdo 延迟5秒, | ||
| 483 | -// onPublisherStop(); | ||
| 484 | - handler.sendEmptyMessageDelayed(Constants.LEAVE_CLASS_CODE,Constants.TIME_NET_ERROR_RECONNECTION); | ||
| 485 | - } | ||
| 486 | - isReconnection=true; | ||
| 487 | - } | ||
| 488 | - } | ||
| 489 | - } | ||
| 490 | - handleListener(type,response); | ||
| 491 | - break; | ||
| 492 | - case Constants.CLASS_EXIT: | ||
| 493 | - /** | ||
| 494 | - * 处理正在推流视频,课堂退出的情况,(用户操作退出界面) | ||
| 495 | - * 此时,停止推流,清除surfaceview Activtity 数据,url数据 | ||
| 496 | - */ | ||
| 497 | - if(isPublisher){ | ||
| 498 | - onPublisherStop(); | ||
| 499 | - } | ||
| 500 | - handleListener(type,response); | ||
| 501 | - break; | ||
| 502 | - default:{ | ||
| 503 | - handleListener(type,response); | ||
| 504 | - } | ||
| 505 | - | ||
| 506 | - } | ||
| 507 | - | ||
| 508 | - } | ||
| 509 | - | ||
| 510 | - /** | ||
| 511 | - * 处理所有向外发送的接口数据 | ||
| 512 | - * @param type | ||
| 513 | - * @param parameter | ||
| 514 | - */ | ||
| 515 | - private void handleListener(String type,String parameter){ | ||
| 516 | - XdyLogUtil.e(TAG,"type:"+type+"parameter:"+parameter); | ||
| 517 | - for(ObserverListener o:observerListenerList){ | ||
| 518 | - o.observerUpData(type,parameter); | ||
| 519 | - } | ||
| 520 | - } | ||
| 521 | - | ||
| 522 | - /** | ||
| 523 | - * 销毁播放音视频 | ||
| 524 | - * @param id | ||
| 525 | - * @return | ||
| 526 | - */ | ||
| 527 | - public boolean onPlayStop(String id){ | ||
| 528 | - if(currentPlayId.equals(id)) { | ||
| 529 | - if (mXdyPlayer != null) { | ||
| 530 | - mXdyPlayer.onStopPlay(); | ||
| 531 | -// mXdyPlayer = null; | ||
| 532 | - | ||
| 533 | - } | ||
| 534 | - return true; | ||
| 535 | - } | ||
| 536 | - return false; | ||
| 537 | - } | ||
| 538 | - /** | ||
| 539 | - * 退出时清除信息(重置js监听) | ||
| 540 | - */ | ||
| 541 | - public void removeAll(){ | ||
| 542 | - if(mXdyPlayer !=null) { | ||
| 543 | - mXdyPlayer.onPause(); | ||
| 544 | - } | ||
| 545 | - if(mXdyJsCore!=null&&!isRecordPlayBack) { | ||
| 546 | - mXdyJsCore.init(mContext); | ||
| 547 | - } | ||
| 548 | - onPublisherStop(); | ||
| 549 | - } | ||
| 550 | - | ||
| 551 | - /** | ||
| 552 | - * 结束时调用 | ||
| 553 | - */ | ||
| 554 | - public void onPlayDestroy(){ | ||
| 555 | - if (mXdyPlayer != null) { | ||
| 556 | - mXdyPlayer.onStopPlay(); | ||
| 557 | - mXdyPlayer = null; | ||
| 558 | - } | ||
| 559 | - | ||
| 560 | - | ||
| 561 | - } | ||
| 562 | - | ||
| 563 | - /** | ||
| 564 | - * 推送视频音频停止方法(最后调用的方法) | ||
| 565 | - * @deprecated daniu sdk handle best | ||
| 566 | - */ | ||
| 567 | - public void onPublisherStop(){ | ||
| 568 | - if(mXdyPublisher !=null){ | ||
| 569 | - mXdyPublisher.onStopPublisher(); | ||
| 570 | - mXdyPublisher =null; | ||
| 571 | - } | ||
| 572 | - //如果正在推流,msurfaceView ,mActivity不清空 | ||
| 573 | - if(!isPublisher) { | ||
| 574 | - if (mSurfaceView_Publish != null) { | ||
| 575 | - mSurfaceView_Publish = null; | ||
| 576 | - } | ||
| 577 | - if (mActivity != null) { | ||
| 578 | - mActivity = null; | ||
| 579 | - } | ||
| 580 | - } | ||
| 581 | - isPublisher =false; | ||
| 582 | - isReconnection=false; | ||
| 583 | - isPublisherAudio=false; | ||
| 584 | - } | ||
| 585 | - | ||
| 586 | - /** | ||
| 587 | - * onPause 方法时走的周期 | ||
| 588 | - * 推送视频暂停调用,单独提出,不与play合并考虑到有后台继续推送的情况 | ||
| 589 | - */ | ||
| 590 | - public void onPublisherPause(){ | ||
| 591 | - if(mXdyPublisher !=null){ | ||
| 592 | - mXdyPublisher.onPausePublisher(); | ||
| 593 | - } | ||
| 594 | - } | ||
| 595 | - | ||
| 596 | - /** | ||
| 597 | - * | ||
| 598 | - * TODO 只有一个boolean | ||
| 599 | - * 开始isPublish 为false | ||
| 600 | - * 开始推流初始化后onresume 就是开始 | ||
| 601 | - * 大牛 sdk处理的更好 | ||
| 602 | - */ | ||
| 603 | - public void onPublisherResume(){ | ||
| 604 | - if(!isPublisher){ | ||
| 605 | - return; | ||
| 606 | - } | ||
| 607 | - if(mXdyPublisher !=null) { | ||
| 608 | - mXdyPublisher.onResumePublisher(); | ||
| 609 | - if (!TextUtils.isEmpty(publish_url)) { | ||
| 610 | - if(!isPublisherAudio){ | ||
| 611 | - mXdyPublisher.publisher(publish_url, mSurfaceView_Publish, new EventHande_Publish()); | ||
| 612 | - }else{ | ||
| 613 | - mXdyPublisher.publisherAudio(publish_url,new EventHande_Publish()); | ||
| 614 | - } | ||
| 615 | - | ||
| 616 | - } | ||
| 617 | - } | ||
| 618 | - } | ||
| 619 | - class EventHande_Play implements SmartEventCallback { | ||
| 620 | - @Override | ||
| 621 | - public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) { | ||
| 622 | - switch (code) { | ||
| 623 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED: | ||
| 624 | - Log.e(TAG, "开始。。"); | ||
| 625 | - break; | ||
| 626 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING: | ||
| 627 | - Log.e(TAG, "连接中。。"); | ||
| 628 | - break; | ||
| 629 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTION_FAILED: | ||
| 630 | - Log.e(TAG, "连接失败。。"); | ||
| 631 | - break; | ||
| 632 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED: | ||
| 633 | - Log.e(TAG, "连接成功。。"); | ||
| 634 | - //TODO //如果连接成功发送连接成功信息,判断的方式有待考虑 | ||
| 635 | -// PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); | ||
| 636 | -// XdySdk.getXdyInstance().notifyObserver("video_success",""); | ||
| 637 | - break; | ||
| 638 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED: | ||
| 639 | - Log.e(TAG, "连接断开。。"); | ||
| 640 | - break; | ||
| 641 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP: | ||
| 642 | - Log.i(TAG, "关闭。。"); | ||
| 643 | - notifyObserver("play_stop",currentPlayId+""); | ||
| 644 | - break; | ||
| 645 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO: | ||
| 646 | - Log.e(TAG, "分辨率信息: width: " + param1 + ", height: " + param2); | ||
| 647 | - //在这里最接近得到播放的成功的准确回调 | ||
| 648 | - notifyObserver(Constants.PLAY_SUCCESS,currentPlayId+""); | ||
| 649 | - break; | ||
| 650 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED: | ||
| 651 | - Log.e(TAG, "收不到媒体数据,可能是url错误。。"); | ||
| 652 | - } | ||
| 653 | - | ||
| 654 | - } | ||
| 655 | - } | ||
| 656 | - | ||
| 657 | - | ||
| 658 | - class EventHande_Publish implements SmartEventCallback { | ||
| 659 | - @Override | ||
| 660 | - public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) { | ||
| 661 | - switch (code) { | ||
| 662 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED: | ||
| 663 | - Log.e(TAG, "开始。。"); | ||
| 664 | - break; | ||
| 665 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING: | ||
| 666 | - Log.e(TAG, "连接中。。"); | ||
| 667 | - break; | ||
| 668 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTION_FAILED: | ||
| 669 | - Log.e(TAG, "连接失败。。"); | ||
| 670 | - break; | ||
| 671 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED: | ||
| 672 | - Log.e(TAG, "连接成功。。"); | ||
| 673 | - //TODO //如果连接成功发送连接成功信息,判断的方式有待考虑 | ||
| 674 | -// PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); | ||
| 675 | -// XdySdk.getXdyInstance().notifyObserver("video_success",""); | ||
| 676 | - break; | ||
| 677 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED: | ||
| 678 | - Log.e(TAG, "连接断开。。"); | ||
| 679 | - break; | ||
| 680 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP: | ||
| 681 | - Log.i(TAG, "关闭。。"); | ||
| 682 | - // notifyObserver("play_stop",currentPlayId+""); | ||
| 683 | - break; | ||
| 684 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO: | ||
| 685 | - Log.e(TAG, "分辨率信息: width: " + param1 + ", height: " + param2); | ||
| 686 | - //在这里最接近得到播放的成功的准确回调 | ||
| 687 | - // notifyObserver(Constants.PLAY_SUCCESS,currentPlayId+""); | ||
| 688 | - break; | ||
| 689 | - case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED: | ||
| 690 | - Log.e(TAG, "收不到媒体数据,可能是url错误。。"); | ||
| 691 | - } | ||
| 692 | - | ||
| 693 | - } | ||
| 694 | - } | ||
| 695 | - /** | ||
| 696 | - * 向后台发送推流数据(Auido)成功信息 | ||
| 697 | - * @param url | ||
| 698 | - */ | ||
| 699 | - protected static void setPublishSendSuccessAudio(String url) { | ||
| 700 | - PublisherSuccessEntity publisherEntity = new PublisherSuccessEntity(); | ||
| 701 | - if (!TextUtils.isEmpty(url)) { | ||
| 702 | - publisherEntity.setPublishUrl(url); | ||
| 703 | - final String pamp = new Gson().toJson(publisherEntity); | ||
| 704 | - XdySdk.getXdyInstance().api(Constants.PUBLISH_AUDIO, pamp); | ||
| 705 | - | ||
| 706 | - } | ||
| 707 | - } | ||
| 708 | - | ||
| 709 | - /** | ||
| 710 | - * 向后台发送推流(Video)成功的信息 | ||
| 711 | - * @param url | ||
| 712 | - */ | ||
| 713 | - protected static void setPublishSendSuccessVideo(String url) { | ||
| 714 | - PublisherSuccessEntity publisherEntity = new PublisherSuccessEntity(); | ||
| 715 | - if (!TextUtils.isEmpty(url)) { | ||
| 716 | - publisherEntity.setPublishUrl(url); | ||
| 717 | - final String pamp = new Gson().toJson(publisherEntity); | ||
| 718 | - XdyLogUtil.e("setPublishSendSuccessVideo:",Thread.currentThread().getId()+""); | ||
| 719 | - XdySdk.getXdyInstance().api(Constants.PUBLISH_VIDEO, pamp); | ||
| 720 | - | ||
| 721 | - } | ||
| 722 | - } | ||
| 723 | -} | 1 | +package com.mang.xdy.core; |
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.os.Handler; | ||
| 6 | +import android.os.Message; | ||
| 7 | +import android.text.TextUtils; | ||
| 8 | +import android.util.Log; | ||
| 9 | +import android.view.SurfaceView; | ||
| 10 | + | ||
| 11 | +import com.eventhandle.SmartEventCallback; | ||
| 12 | +import com.google.gson.Gson; | ||
| 13 | +import com.mang.xdy.bean.GetPublishPathReceiveBean; | ||
| 14 | +import com.mang.xdy.bean.PublisherSuccessEntity; | ||
| 15 | +import com.mang.xdy.bean.VideoPlayBean; | ||
| 16 | +import com.mang.xdy.common.Constants; | ||
| 17 | +import com.mang.xdy.listener.ObserverListener; | ||
| 18 | +import com.mang.xdy.listener.SubjectListener; | ||
| 19 | +import com.mang.xdy.play.XdyPlayer; | ||
| 20 | +import com.mang.xdy.utils.JsonUtil; | ||
| 21 | +import com.mang.xdy.utils.PlayerUtils; | ||
| 22 | +import com.mang.xdy.bean.AudioPlayBean; | ||
| 23 | +import com.mang.xdy.bean.ErrorCodeEntity; | ||
| 24 | +import com.mang.xdy.bean.PublisherVideoReturnBean; | ||
| 25 | +import com.mang.xdy.cache.ACache; | ||
| 26 | +import com.mang.xdy.message.MsgManage; | ||
| 27 | +import com.mang.xdy.play.XdyPublisher; | ||
| 28 | +import com.mang.xdy.utils.NetWorkUtils; | ||
| 29 | +import com.mang.xdy.utils.XdyLogUtil; | ||
| 30 | +import com.mang.xdy.utils.XdyStringUtils; | ||
| 31 | + | ||
| 32 | +import org.json.JSONException; | ||
| 33 | +import org.json.JSONObject; | ||
| 34 | + | ||
| 35 | +import java.util.ArrayList; | ||
| 36 | +import java.util.List; | ||
| 37 | + | ||
| 38 | +/** | ||
| 39 | + * 对外调用的接 | ||
| 40 | + * 受原先的文档设计的规则,所有方法的都是静态的方法,影响性能 | ||
| 41 | + * 考虑跟换文档,提升性能 | ||
| 42 | + */ | ||
| 43 | +public class XdySdk implements SubjectListener { | ||
| 44 | + /** | ||
| 45 | + * 用户初始化,还是调用各种方法,都需要统一的对外给出监听事件 | ||
| 46 | + */ | ||
| 47 | + private static XdyJsCore mXdyJsCore; | ||
| 48 | + private static XdySdk mXdySdk; | ||
| 49 | + private static Context mContext; | ||
| 50 | + private XdyPlayer mXdyPlayer; | ||
| 51 | + private XdyPublisher mXdyPublisher; | ||
| 52 | + /*消息管理*/ | ||
| 53 | + private static MsgManage mMsgManage; | ||
| 54 | + | ||
| 55 | + public static String TAG="xdysdk"; | ||
| 56 | + /*当前播放视频的id*/ | ||
| 57 | + private String currentPlayId=""; | ||
| 58 | + /*缓存管理*/ | ||
| 59 | + private static ACache aCache; | ||
| 60 | + //TODO 拿不到同步的数据先保留信息(必须释放,否者内存泄漏) | ||
| 61 | + private SurfaceView mSurfaceView_Publish; | ||
| 62 | + private Activity mActivity; | ||
| 63 | + /*是否正在推流,mcu自动断开,onPause使用的时候使用,推流成功后才表示正在使用*/ | ||
| 64 | + private boolean isPublisher =false; | ||
| 65 | +// /*Audio 推送中,resume需要使用*/ | ||
| 66 | + private boolean isPublisherAudio=false; | ||
| 67 | + /*推流重连状态,如果是重连状态会有一系列加入课堂的情况*/ | ||
| 68 | + private boolean isReconnection=false; | ||
| 69 | + /*是否进行录制回放*/ | ||
| 70 | + private boolean isRecordPlayBack=false; | ||
| 71 | + /*观察者集合*/ | ||
| 72 | + private List<ObserverListener> observerListenerList=new ArrayList<ObserverListener>(); | ||
| 73 | + /*推流地址*/ | ||
| 74 | + private String publish_url=""; | ||
| 75 | + /*保存nodeid ,自己的唯一标识*/ | ||
| 76 | + private int mNodeId =0; | ||
| 77 | + /*z正在播放视频 onStop 重置状态,是否是Host 在播放视频,这个优先级最高,1v1 产物*/ | ||
| 78 | + private boolean isCurrentVideoHost=false; | ||
| 79 | + private boolean isCurrentAudioHost=false; | ||
| 80 | + | ||
| 81 | + @Override | ||
| 82 | + public void add(ObserverListener observerListener) { | ||
| 83 | + observerListenerList.add(observerListener); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + @Override | ||
| 87 | + public void notifyObserver(String type, String parameter) { | ||
| 88 | + handleData(type,parameter); | ||
| 89 | + XdyLogUtil.e("notifyObserVer","type:"+type+" parameter:"+parameter); | ||
| 90 | + | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + @Override | ||
| 94 | + public void remove(ObserverListener observerListener) { | ||
| 95 | + if(observerListenerList!=null){ | ||
| 96 | + if(observerListenerList.contains(observerListener)) { | ||
| 97 | + observerListenerList.remove(observerListener); | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + private XdySdk(){ | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + private static Handler handler=new Handler(){ | ||
| 105 | + @Override | ||
| 106 | + public void handleMessage(Message msg) { | ||
| 107 | + super.handleMessage(msg); | ||
| 108 | + if(msg.what== Constants.LEAVE_CLASS_CODE){ | ||
| 109 | + if(!NetWorkUtils.isNetworkConnected(mContext)) { | ||
| 110 | + if (mXdySdk != null) { | ||
| 111 | + mXdySdk.onPublisherStop(); | ||
| 112 | + handler.removeCallbacksAndMessages(null); | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + }; | ||
| 118 | + /** | ||
| 119 | + * 初始化 | ||
| 120 | + * @param context | ||
| 121 | + */ | ||
| 122 | + public static void init(final Context context){ | ||
| 123 | + if(context==null){ | ||
| 124 | + throw new IllegalArgumentException(Constants.ERROR_CONTENT_NULL); | ||
| 125 | + } | ||
| 126 | + aCache=ACache.get(context); | ||
| 127 | + mContext=context; | ||
| 128 | + mXdyJsCore = XdyJsCore.getInstance(context); | ||
| 129 | + mMsgManage=MsgManage.getErrorMsgInstance(); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** | ||
| 133 | + * 接收用户传递进来的参数(两个String 的参数都在这里处理) | ||
| 134 | + * @param type 类型 | ||
| 135 | + * @param argument 参数 | ||
| 136 | + */ | ||
| 137 | + public void api(final String type, final String argument){ | ||
| 138 | + judgeCore(); | ||
| 139 | + //再次停止播放器 | ||
| 140 | + switch (type){ | ||
| 141 | + case "stopPublishAudio": | ||
| 142 | + //停止推送音频 | ||
| 143 | + case "stopPublishVideo": | ||
| 144 | + //停止推流video(关闭视频:根据api) | ||
| 145 | + onPublisherStop(); | ||
| 146 | + break; | ||
| 147 | + case "stopAudio": | ||
| 148 | + //停止播放audio() | ||
| 149 | + isCurrentAudioHost=false; | ||
| 150 | + onPlayDestroy(); | ||
| 151 | + break; | ||
| 152 | + case"stopVideo": | ||
| 153 | + //停止播放video( 停止播放:根据api) | ||
| 154 | + isCurrentVideoHost=false; | ||
| 155 | + onPlayDestroy(); | ||
| 156 | + break; | ||
| 157 | + } | ||
| 158 | + if(!isRecordPlayBack &&!judegeNetOK()){ | ||
| 159 | + return; | ||
| 160 | + } | ||
| 161 | + handler.post(new Runnable() { | ||
| 162 | + @Override | ||
| 163 | + public void run() { | ||
| 164 | + mXdyJsCore.native2js(type, argument); | ||
| 165 | + } | ||
| 166 | + }); | ||
| 167 | + | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + /** | ||
| 171 | + * | ||
| 172 | + * @param type | ||
| 173 | + * @param | ||
| 174 | + * @param surfaceView | ||
| 175 | + * @param activity | ||
| 176 | + * @param | ||
| 177 | + * | ||
| 178 | + */ | ||
| 179 | + public void api(String type,String mediaId, SurfaceView surfaceView, Activity activity) { | ||
| 180 | + judgeString(type); | ||
| 181 | + if(!isRecordPlayBack &&!judegeNetOK()){ | ||
| 182 | + return; | ||
| 183 | + } | ||
| 184 | + switch (type) { | ||
| 185 | + case Constants.PLAY_AUDIO: | ||
| 186 | + //判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误 | ||
| 187 | + String json_audio= aCache.getAsString(mediaId); | ||
| 188 | + if(TextUtils.isEmpty(json_audio)){ | ||
| 189 | + //TODO/给出相应的提示表示没有 这个id | ||
| 190 | + XdyLogUtil.e(TAG,"Play Audio Can not find this mediaId"); | ||
| 191 | + return; | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + AudioPlayBean audioPlayBean= JsonUtil.parseJsonToBean(json_audio,AudioPlayBean.class); | ||
| 195 | + if(audioPlayBean!=null) { | ||
| 196 | + String play_url_audio=""; | ||
| 197 | + if(isRecordPlayBack){ | ||
| 198 | + //如果是回放给出。m3u8的id用户 用户需要自己获取play_url_audio=audioPlayBean.getReplay(); | ||
| 199 | + }else{ | ||
| 200 | + //如果是host权限的在播放,下次在播放必须是host | ||
| 201 | + if(isCurrentAudioHost){ | ||
| 202 | + if(!Constants.HOST.equals(audioPlayBean.getUserRole())){ | ||
| 203 | + return; | ||
| 204 | + } | ||
| 205 | + } | ||
| 206 | + if(Constants.HOST.equals(audioPlayBean.getUserRole())){ | ||
| 207 | + isCurrentAudioHost=true; | ||
| 208 | + } | ||
| 209 | + play_url_audio=audioPlayBean.getRtmpUrl() ; | ||
| 210 | + if(mXdyPlayer ==null) { | ||
| 211 | + mXdyPlayer = XdyPlayer.getXdyPlayerCore(play_url_audio, activity); | ||
| 212 | + }else{ | ||
| 213 | + mXdyPlayer.onStopPlay(); | ||
| 214 | + } | ||
| 215 | + mXdyPlayer.playAudio(play_url_audio, new EventHande_Play()); | ||
| 216 | + currentPlayId=mediaId; | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + }else{ | ||
| 220 | + XdyLogUtil.e(TAG,"Can not get play Audio response"); | ||
| 221 | + } | ||
| 222 | + break; | ||
| 223 | + case Constants.PLAY_VIDEO: | ||
| 224 | + //播放视频 | ||
| 225 | + // 判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误 | ||
| 226 | + String json_video= aCache.getAsString(mediaId); | ||
| 227 | + if(TextUtils.isEmpty(json_video)){ | ||
| 228 | + ///给出相应的提示表示没有 这个id | ||
| 229 | + XdyLogUtil.e(TAG,"Play Video Can not find this mediaId"); | ||
| 230 | + return; | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + VideoPlayBean videoPlayBean=JsonUtil.parseJsonToBean(json_video,VideoPlayBean.class); | ||
| 234 | + if(videoPlayBean!=null){ | ||
| 235 | + String play_url_video=""; | ||
| 236 | + if(isRecordPlayBack){ | ||
| 237 | +// play_url_video=videoPlayBean.getReplay(); | ||
| 238 | + }else{ | ||
| 239 | + //如果是host权限的在播放,下次在播放必须是host | ||
| 240 | + if(isCurrentVideoHost){ | ||
| 241 | + if(!Constants.HOST.equals(videoPlayBean.getUserRole())){ | ||
| 242 | + return; | ||
| 243 | + } | ||
| 244 | + } | ||
| 245 | + if(Constants.HOST.equals(videoPlayBean.getUserRole())){ | ||
| 246 | + isCurrentVideoHost=true; | ||
| 247 | + } | ||
| 248 | + play_url_video=videoPlayBean.getRtmpUrl(); | ||
| 249 | + if(mXdyPlayer ==null) { | ||
| 250 | + mXdyPlayer = XdyPlayer.getXdyPlayerCore(play_url_video, activity); | ||
| 251 | + }else{ | ||
| 252 | + //重复播放时候 | ||
| 253 | + mXdyPlayer.onStopPlay(); | ||
| 254 | + } | ||
| 255 | + mXdyPlayer.playVideo(play_url_video, surfaceView,new EventHande_Play()); | ||
| 256 | + currentPlayId=mediaId; | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + }else{ | ||
| 260 | + //统一提示推流错误 | ||
| 261 | + XdyLogUtil.e(TAG,"Can not get play Video response"); | ||
| 262 | + } | ||
| 263 | + break; | ||
| 264 | + case Constants.PUBLISH_VIDEO: | ||
| 265 | + /** | ||
| 266 | + * 用户发起这个推流的请求的时候, | ||
| 267 | + * 1,去获取推流地址 | ||
| 268 | + * 2,判断地址时候有用,有用的话打开播放器,开启推流的过程 | ||
| 269 | + * 3,推流成功告知后台,和用户 | ||
| 270 | + */ | ||
| 271 | + PlayerUtils.getPublishPathVideo(); | ||
| 272 | + mSurfaceView_Publish=surfaceView; | ||
| 273 | + mActivity=activity; | ||
| 274 | + break; | ||
| 275 | + case Constants.PUBLISH_AUDIO: | ||
| 276 | + //只推送音频 | ||
| 277 | + PlayerUtils.getPublishPathAudio(); | ||
| 278 | + mActivity=activity; | ||
| 279 | + break; | ||
| 280 | + | ||
| 281 | + } | ||
| 282 | + } | ||
| 283 | + /*判断是否被初始化*/ | ||
| 284 | + private void judgeCore(){ | ||
| 285 | + if(mXdyJsCore==null){ | ||
| 286 | + throw new IllegalArgumentException(Constants.ERROR_XDYCORE_INIT); | ||
| 287 | + } | ||
| 288 | + } | ||
| 289 | + /*判断type是否为空*/ | ||
| 290 | + private void judgeString(String type){ | ||
| 291 | + if(TextUtils.isEmpty(type)){ | ||
| 292 | + XdyLogUtil.e(TAG,Constants.ERROR_TYPE_NULL); | ||
| 293 | + } | ||
| 294 | + } | ||
| 295 | + /*判断网路是否正常*/ | ||
| 296 | + private boolean judegeNetOK(){ | ||
| 297 | + if( !NetWorkUtils.isNetworkConnected(mContext)){ | ||
| 298 | + String errorJson="{\n" + | ||
| 299 | + " \"code\": 20000,\n" + | ||
| 300 | + " \"reson\": \"无网络连接,请检查网络\"\n" + | ||
| 301 | + "}"; | ||
| 302 | + notifyObserver(Constants.ERROR_CODE, errorJson); | ||
| 303 | + return false; | ||
| 304 | + } | ||
| 305 | + return true; | ||
| 306 | + } | ||
| 307 | + | ||
| 308 | + public static XdySdk getXdyInstance(){ | ||
| 309 | + if(mXdySdk ==null){ | ||
| 310 | + synchronized (XdySdk.class){ | ||
| 311 | + mXdySdk =new XdySdk(); | ||
| 312 | + } | ||
| 313 | + } | ||
| 314 | + return mXdySdk; | ||
| 315 | + } | ||
| 316 | + /** | ||
| 317 | + *core获取到的数据处理 | ||
| 318 | + * @param type | ||
| 319 | + * @param response | ||
| 320 | + */ | ||
| 321 | + private void handleData(String type,String response){ | ||
| 322 | + //开始处理推流信息,用户只需要传递surfaceview activity, 内部处理url | ||
| 323 | + /*需要处理的信息有playVideo 返回的url地址, 遇到video_play ,和 | ||
| 324 | + audio | ||
| 325 | + plublisher Video | ||
| 326 | + publisher Audio | ||
| 327 | + */ | ||
| 328 | + switch (type) { | ||
| 329 | + case Constants.CLASS_JOIN_SUCCESS: | ||
| 330 | + //判断是否是录制回放,调整播流地址 | ||
| 331 | + JSONObject jsonObject = null; | ||
| 332 | + try { | ||
| 333 | + jsonObject = new JSONObject(response); | ||
| 334 | + isRecordPlayBack = jsonObject.optBoolean("isRecordPlayBack"); | ||
| 335 | + mNodeId =jsonObject.optInt("nodeId"); | ||
| 336 | + XdyLogUtil.e("获取的id",""+mNodeId); | ||
| 337 | + } catch (JSONException e) { | ||
| 338 | + e.printStackTrace(); | ||
| 339 | + } | ||
| 340 | + handleListener(type,response); | ||
| 341 | + break; | ||
| 342 | + case Constants.VIDEO_GET_PUBLISH_PATH: | ||
| 343 | + //推流地址的返回值拿到正确的推流地址直接开始推流 | ||
| 344 | + //打开推流视频 | ||
| 345 | +// String publishPath=XdyStringUtils.stringToJson(response); | ||
| 346 | + String publishPath=response; | ||
| 347 | + GetPublishPathReceiveBean getPublishPathReceiveBean=JsonUtil.parseJsonToBean(publishPath,GetPublishPathReceiveBean.class); | ||
| 348 | + if(getPublishPathReceiveBean!=null) { | ||
| 349 | + //可以推流了 | ||
| 350 | + if (getPublishPathReceiveBean.getCode() == 0) { | ||
| 351 | + //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用video_get_publish_path关键字 只支持做只支一路 | ||
| 352 | + String video_url = getPublishPathReceiveBean.getPublishUrl(); | ||
| 353 | + aCache.put(Constants.VIDEO_GET_PUBLISH_PATH, video_url); | ||
| 354 | + //判断 | ||
| 355 | + if (mSurfaceView_Publish == null) { | ||
| 356 | + //todo 输出提示 | ||
| 357 | + throw new IllegalArgumentException(Constants.ERROR_TYPE_SURFACEVIEW); | ||
| 358 | + } | ||
| 359 | + if (mActivity == null) { | ||
| 360 | + //TODo 给出提示 | ||
| 361 | + throw new IllegalArgumentException(Constants.ERROR_TYPE_ACTIVITY); | ||
| 362 | + } | ||
| 363 | + if (mXdyPublisher == null) { | ||
| 364 | + mXdyPublisher = new XdyPublisher(1, 1, mActivity); | ||
| 365 | + }else{ | ||
| 366 | + //todo 如果不为空的话是已经播放过,得清理上次的 | ||
| 367 | +// mXdyPlayer.onPause(); | ||
| 368 | + } | ||
| 369 | + publish_url=video_url; | ||
| 370 | + isPublisher =true; | ||
| 371 | + isPublisherAudio=false; | ||
| 372 | + mXdyPublisher.publisher(video_url,mSurfaceView_Publish, new EventHande_Publish()); | ||
| 373 | +// PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); | ||
| 374 | + //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断) | ||
| 375 | + setPublishSendSuccessVideo(video_url); | ||
| 376 | + }else{ | ||
| 377 | + mMsgManage.getPublishVideoPathError(); | ||
| 378 | + } | ||
| 379 | + }else{ | ||
| 380 | + //给出提示 | ||
| 381 | + //TODO | ||
| 382 | + handleListener(Constants.ERROR_CODE,"{\n" + | ||
| 383 | + " \"code\": 804,\n" + | ||
| 384 | + " \"reson\": \"推流失败\"\n" + | ||
| 385 | + "}"); | ||
| 386 | + } | ||
| 387 | + break; | ||
| 388 | + case Constants.AUDIO_GET_PUBLISH_PATH: | ||
| 389 | + //推流地址的返回值拿到正确的推流地址直接开始推流 | ||
| 390 | + //打开推流视频 | ||
| 391 | + String audio_path=response; | ||
| 392 | + GetPublishPathReceiveBean getPublishPathReceiveBean_Audio=JsonUtil.parseJsonToBean(audio_path,GetPublishPathReceiveBean.class); | ||
| 393 | + if(getPublishPathReceiveBean_Audio!=null&&getPublishPathReceiveBean_Audio.getCode()==0){ | ||
| 394 | + //可以推流了 | ||
| 395 | + String audio_url=getPublishPathReceiveBean_Audio.getPublishUrl(); | ||
| 396 | + //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用getvideopublishpath 做关键字 | ||
| 397 | + aCache.put(Constants.GET_AUDIO_PUBLISH_PATH,audio_url); | ||
| 398 | + //判断 | ||
| 399 | +// if (mSurfaceView==null){ | ||
| 400 | +// //todo 输出提示 | ||
| 401 | +// XdyLogUtil.e(TAG,"surfaceView is null"); | ||
| 402 | +// return; | ||
| 403 | +// } | ||
| 404 | + if(mActivity==null){ | ||
| 405 | + //TODo 给出提示 | ||
| 406 | + XdyLogUtil.e(TAG,"activity is null"); | ||
| 407 | + return; | ||
| 408 | + } | ||
| 409 | + if(mXdyPublisher ==null) { | ||
| 410 | + mXdyPublisher = new XdyPublisher(1, 0, mActivity); | ||
| 411 | + }else { | ||
| 412 | + //todo 如果不为空的话是已经播放过,得清理上次的 | ||
| 413 | +// mXdyPlayer.onPause(); | ||
| 414 | + } | ||
| 415 | + mXdyPublisher.publisherAudio(audio_url,new EventHande_Publish()); | ||
| 416 | + publish_url=audio_url; | ||
| 417 | + isPublisher =true; | ||
| 418 | + isPublisherAudio=true; | ||
| 419 | + //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断) | ||
| 420 | + PlayerUtils.setPublishSendSuccessAudio(audio_url); | ||
| 421 | + }else{ | ||
| 422 | + //给出提示 | ||
| 423 | + //TODO | ||
| 424 | + handleListener(Constants.ERROR_CODE,"{\n" + | ||
| 425 | + " \"code\": 804,\n" + | ||
| 426 | + " \"reson\": \"推流失败\"\n" + | ||
| 427 | + "}"); | ||
| 428 | + } | ||
| 429 | + break; | ||
| 430 | + case Constants.PUBLISH_AUDIO: | ||
| 431 | + //只推送音频 | ||
| 432 | + //接收后台是否接收到推流URl的地址 | ||
| 433 | + String publishReplay_Audio=response; | ||
| 434 | + XdyLogUtil.e(TAG,"后台成功接收到,返回值"+XdyStringUtils.stringToJson(publishReplay_Audio)); | ||
| 435 | + PublisherVideoReturnBean publisherVideoReturnBean_audio=JsonUtil.parseJsonToBean(XdyStringUtils.stringToJson(publishReplay_Audio),PublisherVideoReturnBean.class); | ||
| 436 | + if(publisherVideoReturnBean_audio!=null&&publisherVideoReturnBean_audio.getCode()==0){ | ||
| 437 | + XdyLogUtil.e(TAG,"后台成功接收到,推流的地址"); | ||
| 438 | + //TODO | ||
| 439 | + | ||
| 440 | + handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); | ||
| 441 | + }else{ | ||
| 442 | + //TODO | ||
| 443 | + handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); | ||
| 444 | + } | ||
| 445 | + break; | ||
| 446 | + case Constants.VIDEO_PUBLISH_RESULT: | ||
| 447 | + //接收发送推流地址给后台返回的信息 | ||
| 448 | + String publishReplay=response; | ||
| 449 | + XdyLogUtil.e(TAG,"后台成功接收到,返回值"+XdyStringUtils.stringToJson(publishReplay)); | ||
| 450 | + PublisherVideoReturnBean publisherVideoReturnBean=JsonUtil.parseJsonToBean(publishReplay,PublisherVideoReturnBean.class); | ||
| 451 | + if(publisherVideoReturnBean!=null&&publisherVideoReturnBean.getCode()==0){ | ||
| 452 | + XdyLogUtil.e(TAG,"后台成功接收到,推流的地址"); | ||
| 453 | + //TODO | ||
| 454 | + | ||
| 455 | + handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); | ||
| 456 | + }else{ | ||
| 457 | + //TODO | ||
| 458 | + handleListener(Constants.ERROR_CODE,"{\n" + | ||
| 459 | + " \"code\": 804,\n" + | ||
| 460 | + " \"reson\": \"推流失败\"\n" + | ||
| 461 | + "}"); | ||
| 462 | + } | ||
| 463 | + break; | ||
| 464 | + case Constants.VIDEO_PLAY: | ||
| 465 | + //获取推流的地址,需要保存起来 | ||
| 466 | + //解析数据拿出mediaId 作为主键 将media 释放的给用户可能有多个播放的情况 | ||
| 467 | + String video=response; | ||
| 468 | + VideoPlayBean videoPlayBean= JsonUtil.parseJsonToBean(video,VideoPlayBean.class); | ||
| 469 | + if(videoPlayBean!=null) { | ||
| 470 | +// if(videoPlayBean.getMediaId()!=videoPlayBean.getFromNodeId()) { | ||
| 471 | + if(mNodeId !=videoPlayBean.getFromNodeId()) { | ||
| 472 | + //过滤自己推送的video | ||
| 473 | + aCache.put(videoPlayBean.getMediaId() + "", video); | ||
| 474 | + handleListener(type, videoPlayBean.getMediaId() + ""); | ||
| 475 | + } | ||
| 476 | + }else{ | ||
| 477 | + XdyLogUtil.e(TAG,"video play json error"); | ||
| 478 | + } | ||
| 479 | + break; | ||
| 480 | + case Constants.AUDIO_PLAY: | ||
| 481 | + String audio=response; | ||
| 482 | + AudioPlayBean audioPlayBean=JsonUtil.parseJsonToBean(audio,AudioPlayBean.class); | ||
| 483 | + if(audioPlayBean!=null){ | ||
| 484 | +// if(audioPlayBean.getMediaId()!=audioPlayBean.getFromNodeId()) { | ||
| 485 | + if(mNodeId !=audioPlayBean.getFromNodeId()) { | ||
| 486 | + aCache.put(audioPlayBean.getMediaId() + "", audio); | ||
| 487 | + handleListener(type, audioPlayBean.getMediaId() + ""); | ||
| 488 | + } | ||
| 489 | + } | ||
| 490 | + break; | ||
| 491 | + case Constants.ERROR_CODE: | ||
| 492 | + ErrorCodeEntity errorCodeEntity =JsonUtil.parseJsonToBean(response,ErrorCodeEntity.class); | ||
| 493 | + if(errorCodeEntity!=null){ | ||
| 494 | + if(errorCodeEntity.getCode()==Constants.LEAVE_CLASS_CODE){ | ||
| 495 | + /** | ||
| 496 | + * 方案 一 1,正在直播的时候mcu无故断开,需要重新连接 | ||
| 497 | + * 2,class exit 时候主动课堂停止,停止推流 | ||
| 498 | + * 利用mcu的生命周期,加入课堂成功后去请求数据 | ||
| 499 | + */ | ||
| 500 | + // 方案 二 mcu 断开,页面也断开,用户需要手动重新调用 | ||
| 501 | + if(isPublisher) { | ||
| 502 | + if(!NetWorkUtils.isNetworkConnected(mContext)){ | ||
| 503 | + //todo判断是否有网络,没有网络的话就让其退出 | ||
| 504 | + // TOdo 延迟5秒, | ||
| 505 | +// onPublisherStop(); | ||
| 506 | + handler.sendEmptyMessageDelayed(Constants.LEAVE_CLASS_CODE,Constants.TIME_NET_ERROR_RECONNECTION); | ||
| 507 | + } | ||
| 508 | + isReconnection=true; | ||
| 509 | + } | ||
| 510 | + } | ||
| 511 | + } | ||
| 512 | + handleListener(type,response); | ||
| 513 | + break; | ||
| 514 | + case Constants.CLASS_EXIT: | ||
| 515 | + /** | ||
| 516 | + * 处理正在推流视频,课堂退出的情况,(用户操作退出界面) | ||
| 517 | + * 此时,停止推流,清除surfaceview Activtity 数据,url数据 | ||
| 518 | + */ | ||
| 519 | + if(isPublisher){ | ||
| 520 | + onPublisherStop(); | ||
| 521 | + } | ||
| 522 | + handleListener(type,response); | ||
| 523 | + break; | ||
| 524 | + default:{ | ||
| 525 | + handleListener(type,response); | ||
| 526 | + } | ||
| 527 | + | ||
| 528 | + } | ||
| 529 | + | ||
| 530 | + } | ||
| 531 | + | ||
| 532 | + /** | ||
| 533 | + * 处理所有向外发送的接口数据 | ||
| 534 | + * @param type | ||
| 535 | + * @param parameter | ||
| 536 | + */ | ||
| 537 | + private void handleListener(String type,String parameter){ | ||
| 538 | + XdyLogUtil.e(TAG,"type:"+type+"parameter:"+parameter); | ||
| 539 | + for(ObserverListener o:observerListenerList){ | ||
| 540 | + o.observerUpData(type,parameter); | ||
| 541 | + } | ||
| 542 | + } | ||
| 543 | + | ||
| 544 | + /** | ||
| 545 | + * 销毁播放音视频 | ||
| 546 | + * @param id | ||
| 547 | + * @return | ||
| 548 | + */ | ||
| 549 | + public boolean onPlayStop(String id){ | ||
| 550 | + if(currentPlayId.equals(id)) { | ||
| 551 | + if (mXdyPlayer != null) { | ||
| 552 | + mXdyPlayer.onStopPlay(); | ||
| 553 | +// mXdyPlayer = null; | ||
| 554 | + | ||
| 555 | + isCurrentAudioHost=false; | ||
| 556 | + isCurrentVideoHost=false; | ||
| 557 | + | ||
| 558 | + | ||
| 559 | + } | ||
| 560 | + return true; | ||
| 561 | + } | ||
| 562 | + return false; | ||
| 563 | + } | ||
| 564 | + /** | ||
| 565 | + * 退出时清除信息(重置js监听) | ||
| 566 | + */ | ||
| 567 | + public void removeAll(){ | ||
| 568 | + if(mXdyPlayer !=null) { | ||
| 569 | + mXdyPlayer.onPause(); | ||
| 570 | + } | ||
| 571 | + if(mXdyJsCore!=null&&!isRecordPlayBack) { | ||
| 572 | + mXdyJsCore.init(mContext); | ||
| 573 | + } | ||
| 574 | + isCurrentVideoHost=false; | ||
| 575 | + isCurrentAudioHost=false; | ||
| 576 | + onPublisherStop(); | ||
| 577 | + } | ||
| 578 | + | ||
| 579 | + /** | ||
| 580 | + * 结束时调用 | ||
| 581 | + */ | ||
| 582 | + public void onPlayDestroy(){ | ||
| 583 | + if (mXdyPlayer != null) { | ||
| 584 | + mXdyPlayer.onStopPlay(); | ||
| 585 | + mXdyPlayer = null; | ||
| 586 | + } | ||
| 587 | + | ||
| 588 | + | ||
| 589 | + } | ||
| 590 | + | ||
| 591 | + /** | ||
| 592 | + * 推送视频音频停止方法(最后调用的方法) | ||
| 593 | + * @deprecated daniu sdk handle best | ||
| 594 | + */ | ||
| 595 | + public void onPublisherStop(){ | ||
| 596 | + if(mXdyPublisher !=null){ | ||
| 597 | + mXdyPublisher.onStopPublisher(); | ||
| 598 | + mXdyPublisher =null; | ||
| 599 | + } | ||
| 600 | + //如果正在推流,msurfaceView ,mActivity不清空 | ||
| 601 | + if(!isPublisher) { | ||
| 602 | + if (mSurfaceView_Publish != null) { | ||
| 603 | + mSurfaceView_Publish = null; | ||
| 604 | + } | ||
| 605 | + if (mActivity != null) { | ||
| 606 | + mActivity = null; | ||
| 607 | + } | ||
| 608 | + } | ||
| 609 | + isPublisher =false; | ||
| 610 | + isReconnection=false; | ||
| 611 | + isPublisherAudio=false; | ||
| 612 | + } | ||
| 613 | + | ||
| 614 | + /** | ||
| 615 | + * onPause 方法时走的周期 | ||
| 616 | + * 推送视频暂停调用,单独提出,不与play合并考虑到有后台继续推送的情况 | ||
| 617 | + */ | ||
| 618 | + public void onPublisherPause(){ | ||
| 619 | + if(mXdyPublisher !=null){ | ||
| 620 | + mXdyPublisher.onPausePublisher(); | ||
| 621 | + } | ||
| 622 | + } | ||
| 623 | + | ||
| 624 | + /** | ||
| 625 | + * | ||
| 626 | + * TODO 只有一个boolean | ||
| 627 | + * 开始isPublish 为false | ||
| 628 | + * 开始推流初始化后onresume 就是开始 | ||
| 629 | + * 大牛 sdk处理的更好 | ||
| 630 | + */ | ||
| 631 | + public void onPublisherResume(){ | ||
| 632 | + if(!isPublisher){ | ||
| 633 | + return; | ||
| 634 | + } | ||
| 635 | + if(mXdyPublisher !=null) { | ||
| 636 | + mXdyPublisher.onResumePublisher(); | ||
| 637 | + if (!TextUtils.isEmpty(publish_url)) { | ||
| 638 | + if(!isPublisherAudio){ | ||
| 639 | + mXdyPublisher.publisher(publish_url, mSurfaceView_Publish, new EventHande_Publish()); | ||
| 640 | + }else{ | ||
| 641 | + mXdyPublisher.publisherAudio(publish_url,new EventHande_Publish()); | ||
| 642 | + } | ||
| 643 | + | ||
| 644 | + } | ||
| 645 | + } | ||
| 646 | + } | ||
| 647 | + class EventHande_Play implements SmartEventCallback { | ||
| 648 | + @Override | ||
| 649 | + public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) { | ||
| 650 | + switch (code) { | ||
| 651 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED: | ||
| 652 | + Log.e(TAG, "开始。。"); | ||
| 653 | + break; | ||
| 654 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING: | ||
| 655 | + Log.e(TAG, "连接中。。"); | ||
| 656 | + break; | ||
| 657 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTION_FAILED: | ||
| 658 | + Log.e(TAG, "连接失败。。"); | ||
| 659 | + break; | ||
| 660 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED: | ||
| 661 | + Log.e(TAG, "连接成功。。"); | ||
| 662 | + //TODO //如果连接成功发送连接成功信息,判断的方式有待考虑 | ||
| 663 | +// PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); | ||
| 664 | +// XdySdk.getXdyInstance().notifyObserver("video_success",""); | ||
| 665 | + break; | ||
| 666 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED: | ||
| 667 | + Log.e(TAG, "连接断开。。"); | ||
| 668 | + break; | ||
| 669 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP: | ||
| 670 | + Log.i(TAG, "关闭。。"); | ||
| 671 | + notifyObserver("play_stop",currentPlayId+""); | ||
| 672 | + break; | ||
| 673 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO: | ||
| 674 | + Log.e(TAG, "分辨率信息: width: " + param1 + ", height: " + param2); | ||
| 675 | + //在这里最接近得到播放的成功的准确回调 | ||
| 676 | + notifyObserver(Constants.PLAY_SUCCESS,currentPlayId+""); | ||
| 677 | + break; | ||
| 678 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED: | ||
| 679 | + Log.e(TAG, "收不到媒体数据,可能是url错误。。"); | ||
| 680 | + } | ||
| 681 | + | ||
| 682 | + } | ||
| 683 | + } | ||
| 684 | + | ||
| 685 | + | ||
| 686 | + class EventHande_Publish implements SmartEventCallback { | ||
| 687 | + @Override | ||
| 688 | + public void onCallback(int code, long param1, long param2, String param3, String param4, Object param5) { | ||
| 689 | + switch (code) { | ||
| 690 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED: | ||
| 691 | + Log.e(TAG, "开始。。"); | ||
| 692 | + break; | ||
| 693 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING: | ||
| 694 | + Log.e(TAG, "连接中。。"); | ||
| 695 | + break; | ||
| 696 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTION_FAILED: | ||
| 697 | + Log.e(TAG, "连接失败。。"); | ||
| 698 | + break; | ||
| 699 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED: | ||
| 700 | + Log.e(TAG, "连接成功。。"); | ||
| 701 | + //TODO //如果连接成功发送连接成功信息,判断的方式有待考虑 | ||
| 702 | +// PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); | ||
| 703 | +// XdySdk.getXdyInstance().notifyObserver("video_success",""); | ||
| 704 | + break; | ||
| 705 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED: | ||
| 706 | + Log.e(TAG, "连接断开。。"); | ||
| 707 | + break; | ||
| 708 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STOP: | ||
| 709 | + Log.i(TAG, "关闭。。"); | ||
| 710 | + // notifyObserver("play_stop",currentPlayId+""); | ||
| 711 | + break; | ||
| 712 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_RESOLUTION_INFO: | ||
| 713 | + Log.e(TAG, "分辨率信息: width: " + param1 + ", height: " + param2); | ||
| 714 | + //在这里最接近得到播放的成功的准确回调 | ||
| 715 | + // notifyObserver(Constants.PLAY_SUCCESS,currentPlayId+""); | ||
| 716 | + break; | ||
| 717 | + case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_NO_MEDIADATA_RECEIVED: | ||
| 718 | + Log.e(TAG, "收不到媒体数据,可能是url错误。。"); | ||
| 719 | + } | ||
| 720 | + | ||
| 721 | + } | ||
| 722 | + } | ||
| 723 | + /** | ||
| 724 | + * 向后台发送推流数据(Auido)成功信息 | ||
| 725 | + * @param url | ||
| 726 | + */ | ||
| 727 | + protected static void setPublishSendSuccessAudio(String url) { | ||
| 728 | + PublisherSuccessEntity publisherEntity = new PublisherSuccessEntity(); | ||
| 729 | + if (!TextUtils.isEmpty(url)) { | ||
| 730 | + publisherEntity.setPublishUrl(url); | ||
| 731 | + final String pamp = new Gson().toJson(publisherEntity); | ||
| 732 | + XdySdk.getXdyInstance().api(Constants.PUBLISH_AUDIO, pamp); | ||
| 733 | + | ||
| 734 | + } | ||
| 735 | + } | ||
| 736 | + | ||
| 737 | + /** | ||
| 738 | + * 向后台发送推流(Video)成功的信息 | ||
| 739 | + * @param url | ||
| 740 | + */ | ||
| 741 | + protected static void setPublishSendSuccessVideo(String url) { | ||
| 742 | + PublisherSuccessEntity publisherEntity = new PublisherSuccessEntity(); | ||
| 743 | + if (!TextUtils.isEmpty(url)) { | ||
| 744 | + publisherEntity.setPublishUrl(url); | ||
| 745 | + final String pamp = new Gson().toJson(publisherEntity); | ||
| 746 | + XdyLogUtil.e("setPublishSendSuccessVideo:",Thread.currentThread().getId()+""); | ||
| 747 | + XdySdk.getXdyInstance().api(Constants.PUBLISH_VIDEO, pamp); | ||
| 748 | + | ||
| 749 | + } | ||
| 750 | + } | ||
| 751 | +} |
| 1 | -package com.mang.xdy.utils; | ||
| 2 | - | ||
| 3 | -import android.text.TextUtils; | ||
| 4 | -import android.util.Log; | ||
| 5 | - | ||
| 6 | -import com.google.gson.Gson; | ||
| 7 | -import com.google.gson.reflect.TypeToken; | ||
| 8 | - | ||
| 9 | -import org.json.JSONException; | ||
| 10 | -import org.json.JSONObject; | ||
| 11 | - | ||
| 12 | -import java.lang.reflect.Type; | ||
| 13 | -import java.util.HashMap; | ||
| 14 | -import java.util.List; | ||
| 15 | -import java.util.Map; | ||
| 16 | - | ||
| 17 | -/** | ||
| 18 | - * 封装的是使用Gson解析json的方法 | ||
| 19 | - * | ||
| 20 | - * @author abao | ||
| 21 | - */ | ||
| 22 | -public class JsonUtil { | ||
| 23 | - | ||
| 24 | - private static final String TAG = JsonUtil.class.getSimpleName(); | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * 把一个map变成json字符串 | ||
| 28 | - * | ||
| 29 | - * @param map | ||
| 30 | - * @return | ||
| 31 | - */ | ||
| 32 | - public static String parseMapToJson(Map<?, ?> map) { | ||
| 33 | - try { | ||
| 34 | - Gson gson = new Gson(); | ||
| 35 | - return gson.toJson(map); | ||
| 36 | - } catch (Exception e) { | ||
| 37 | - } | ||
| 38 | - return null; | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - public static String parseListToJson(List<?> list) { | ||
| 42 | - try { | ||
| 43 | - Gson gson = new Gson(); | ||
| 44 | - return gson.toJson(list); | ||
| 45 | - } catch (Exception e) { | ||
| 46 | - } | ||
| 47 | - return null; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - /** | ||
| 51 | - * 把一个json字符串变成对象 | ||
| 52 | - * | ||
| 53 | - * @param json | ||
| 54 | - * @param cls | ||
| 55 | - * @return | ||
| 56 | - */ | ||
| 57 | - public static <T> T parseJsonToBean(String json, Class<T> cls) { | ||
| 58 | - Gson gson = new Gson(); | ||
| 59 | - T t = null; | ||
| 60 | - try { | ||
| 61 | - t = gson.fromJson(json, cls); | ||
| 62 | - } catch (Exception e) { | ||
| 63 | - Log.e(TAG,e.getMessage()); | ||
| 64 | - e.printStackTrace(); | ||
| 65 | - } | ||
| 66 | - return t; | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - /** | ||
| 70 | - * 把json字符串变成map | ||
| 71 | - * | ||
| 72 | - * @param json | ||
| 73 | - * @return | ||
| 74 | - */ | ||
| 75 | - public static HashMap<String, Object> parseJsonToMap(String json) { | ||
| 76 | - Gson gson = new Gson(); | ||
| 77 | - Type type = new TypeToken<HashMap<String, Object>>() { | ||
| 78 | - }.getType(); | ||
| 79 | - HashMap<String, Object> map = null; | ||
| 80 | - try { | ||
| 81 | - map = gson.fromJson(json, type); | ||
| 82 | - } catch (Exception e) { | ||
| 83 | - } | ||
| 84 | - return map; | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - /** | ||
| 88 | - * 把json字符串变成集合 | ||
| 89 | - * params: new TypeToken<List<yourbean>>(){}.getType(), | ||
| 90 | - * | ||
| 91 | - * @param json | ||
| 92 | - * @param type new TypeToken<List<yourbean>>(){}.getType() | ||
| 93 | - * @return | ||
| 94 | - */ | ||
| 95 | - public static List<?> parseJsonToList(String json, Type type) { | ||
| 96 | - Gson gson = new Gson(); | ||
| 97 | - List<?> list = gson.fromJson(json, type); | ||
| 98 | - return list; | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - /** | ||
| 102 | - * 获取json串中某个字段的值,注意,只能获取同一层级的value | ||
| 103 | - * | ||
| 104 | - * @param json | ||
| 105 | - * @param key | ||
| 106 | - * @return | ||
| 107 | - */ | ||
| 108 | - public static String getFieldValue(String json, String key) { | ||
| 109 | - if (TextUtils.isEmpty(json)) | ||
| 110 | - return null; | ||
| 111 | - if (!json.contains(key)) | ||
| 112 | - return ""; | ||
| 113 | - JSONObject jsonObject = null; | ||
| 114 | - String value = null; | ||
| 115 | - try { | ||
| 116 | - jsonObject = new JSONObject(json); | ||
| 117 | - value = jsonObject.getString(key); | ||
| 118 | - } catch (JSONException e) { | ||
| 119 | - e.printStackTrace(); | ||
| 120 | - } | ||
| 121 | - return value; | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | -} | 1 | +package com.mang.xdy.utils; |
| 2 | + | ||
| 3 | +import android.text.TextUtils; | ||
| 4 | +import android.util.Log; | ||
| 5 | + | ||
| 6 | +import com.google.gson.Gson; | ||
| 7 | +import com.google.gson.reflect.TypeToken; | ||
| 8 | + | ||
| 9 | +import org.json.JSONException; | ||
| 10 | +import org.json.JSONObject; | ||
| 11 | + | ||
| 12 | +import java.lang.reflect.Type; | ||
| 13 | +import java.util.HashMap; | ||
| 14 | +import java.util.List; | ||
| 15 | +import java.util.Map; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * 封装的是使用Gson解析json的方法 | ||
| 19 | + * | ||
| 20 | + * @author abao | ||
| 21 | + */ | ||
| 22 | +public class JsonUtil { | ||
| 23 | + | ||
| 24 | + private static final String TAG = JsonUtil.class.getSimpleName(); | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 把一个map变成json字符串 | ||
| 28 | + * | ||
| 29 | + * @param map | ||
| 30 | + * @return | ||
| 31 | + */ | ||
| 32 | + public static String parseMapToJson(Map<?, ?> map) { | ||
| 33 | + try { | ||
| 34 | + Gson gson = new Gson(); | ||
| 35 | + return gson.toJson(map); | ||
| 36 | + } catch (Exception e) { | ||
| 37 | + } | ||
| 38 | + return null; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public static String parseListToJson(List<?> list) { | ||
| 42 | + try { | ||
| 43 | + Gson gson = new Gson(); | ||
| 44 | + return gson.toJson(list); | ||
| 45 | + } catch (Exception e) { | ||
| 46 | + } | ||
| 47 | + return null; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 把一个json字符串变成对象 | ||
| 52 | + * | ||
| 53 | + * @param json | ||
| 54 | + * @param cls | ||
| 55 | + * @return | ||
| 56 | + */ | ||
| 57 | + public static <T> T parseJsonToBean(String json, Class<T> cls) { | ||
| 58 | + Gson gson = new Gson(); | ||
| 59 | + T t = null; | ||
| 60 | + try { | ||
| 61 | + t = gson.fromJson(json, cls); | ||
| 62 | + } catch (Exception e) { | ||
| 63 | + Log.e(TAG,e.getMessage()); | ||
| 64 | + e.printStackTrace(); | ||
| 65 | + } | ||
| 66 | + return t; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 把json字符串变成map | ||
| 71 | + * | ||
| 72 | + * @param json | ||
| 73 | + * @return | ||
| 74 | + */ | ||
| 75 | + public static HashMap<String, Object> parseJsonToMap(String json) { | ||
| 76 | + Gson gson = new Gson(); | ||
| 77 | + Type type = new TypeToken<HashMap<String, Object>>() { | ||
| 78 | + }.getType(); | ||
| 79 | + HashMap<String, Object> map = null; | ||
| 80 | + try { | ||
| 81 | + map = gson.fromJson(json, type); | ||
| 82 | + } catch (Exception e) { | ||
| 83 | + } | ||
| 84 | + return map; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 把json字符串变成集合 | ||
| 89 | + * params: new TypeToken<List<yourbean>>(){}.getType(), | ||
| 90 | + * | ||
| 91 | + * @param json | ||
| 92 | + * @param type new TypeToken<List<yourbean>>(){}.getType() | ||
| 93 | + * @return | ||
| 94 | + */ | ||
| 95 | + public static List<?> parseJsonToList(String json, Type type) { | ||
| 96 | + Gson gson = new Gson(); | ||
| 97 | + List<?> list = gson.fromJson(json, type); | ||
| 98 | + return list; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * 获取json串中某个字段的值,注意,只能获取同一层级的value | ||
| 103 | + * | ||
| 104 | + * @param json | ||
| 105 | + * @param key | ||
| 106 | + * @return | ||
| 107 | + */ | ||
| 108 | + public static String getFieldValue(String json, String key) { | ||
| 109 | + if (TextUtils.isEmpty(json)) | ||
| 110 | + return null; | ||
| 111 | + if (!json.contains(key)) | ||
| 112 | + return ""; | ||
| 113 | + JSONObject jsonObject = null; | ||
| 114 | + String value = null; | ||
| 115 | + try { | ||
| 116 | + jsonObject = new JSONObject(json); | ||
| 117 | + value = jsonObject.getString(key); | ||
| 118 | + } catch (JSONException e) { | ||
| 119 | + e.printStackTrace(); | ||
| 120 | + } | ||
| 121 | + return value; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | +} |
| 1 | +package com.mang.xdy.utils; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.content.SharedPreferences; | ||
| 5 | + | ||
| 6 | +import java.io.ByteArrayOutputStream; | ||
| 7 | +import java.io.IOException; | ||
| 8 | +import java.io.InputStream; | ||
| 9 | + | ||
| 10 | + | ||
| 11 | +public class SPUtil { | ||
| 12 | + private static SharedPreferences mSp; | ||
| 13 | + | ||
| 14 | + private static SharedPreferences getSharedPreferences(Context context) { | ||
| 15 | + if (mSp == null) { | ||
| 16 | + mSp = context.getSharedPreferences("config", Context.MODE_PRIVATE); | ||
| 17 | + } | ||
| 18 | + return mSp; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public static void putBoolean(Context context, String key, boolean value) { | ||
| 22 | + // SharedPreferences sp = mContext.getSharedPreferences("config", | ||
| 23 | + // Context.MODE_PRIVATE); | ||
| 24 | + getSharedPreferences(context).edit().putBoolean(key, value).commit(); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public static boolean getBoolean(Context context, String key, boolean defValue) { | ||
| 28 | + // SharedPreferences sp = mContext.getSharedPreferences("config", | ||
| 29 | + // Context.MODE_PRIVATE); | ||
| 30 | + return getSharedPreferences(context).getBoolean(key, defValue); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public static void putString(Context context, String key, String value) { | ||
| 34 | + getSharedPreferences(context).edit().putString(key, value).commit(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public static String getString(Context context, String key, String defValue) { | ||
| 38 | + return getSharedPreferences(context).getString(key, defValue); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public static void putInt(Context context, String key, int value) { | ||
| 42 | + getSharedPreferences(context).edit().putInt(key, value).commit(); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public static int getInt(Context context, String key, int defValue) { | ||
| 46 | + return getSharedPreferences(context).getInt(key, defValue); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * 移除一个字符串值 | ||
| 51 | + * | ||
| 52 | + * @param context | ||
| 53 | + * @param key | ||
| 54 | + */ | ||
| 55 | + public static void removeString(Context context, String key) { | ||
| 56 | + getSharedPreferences(context).edit().remove(key).commit(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 把流里的内容解析成字符串 | ||
| 61 | + * | ||
| 62 | + * @param is | ||
| 63 | + * @return | ||
| 64 | + * @throws IOException | ||
| 65 | + */ | ||
| 66 | + public static String streamToString(InputStream is) throws IOException { | ||
| 67 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| 68 | + byte[] buffer = new byte[1024]; | ||
| 69 | + int len = -1; | ||
| 70 | + while ((len = is.read(buffer)) != -1) { | ||
| 71 | + baos.write(buffer, 0, len); | ||
| 72 | + } | ||
| 73 | + String string = baos.toString(); | ||
| 74 | + baos.close(); | ||
| 75 | + is.close(); | ||
| 76 | + return string; | ||
| 77 | + } | ||
| 78 | + public static long getLong(String key,long defValue) { | ||
| 79 | + return mSp.getLong(key, defValue); | ||
| 80 | + } | ||
| 81 | + public static void setLong(Context context, String key, Long value) { | ||
| 82 | + getSharedPreferences(context).edit().putLong(key, value).commit(); | ||
| 83 | + } | ||
| 84 | +} |
| 1 | -package com.mang.xdy.utils; | ||
| 2 | - | ||
| 3 | -import android.content.Context; | ||
| 4 | -import android.text.TextUtils; | ||
| 5 | -import android.util.Log; | ||
| 6 | - | ||
| 7 | -import java.util.Locale; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * Created by abao on 2017/3/30. | ||
| 11 | - */ | ||
| 12 | - | ||
| 13 | -public class XdyStringUtils { | ||
| 14 | - private static String TAG="xdysdk"; | ||
| 15 | - public static String stringToJson(String s,boolean isJSjson){ | ||
| 16 | - StringBuffer sb = new StringBuffer(); | ||
| 17 | - for(int i=0; i<s.length(); i++){ | ||
| 18 | - char c =s.charAt(i); | ||
| 19 | - switch(c){ | ||
| 20 | - case'\'': if(isJSjson) {sb.append("\\\'");}else{sb.append("\'");} break; | ||
| 21 | - case'\"': if(!isJSjson) {sb.append("\\\"");}else{sb.append("\"");} break; | ||
| 22 | - case'\\':sb.append("\\\\"); break; //如果不处理单引号,可以释放此段代码,若结合StringDanYinToJSON()处理单引号就必须注释掉该段代码 | ||
| 23 | - case'/': sb.append("\\/");break; | ||
| 24 | - case'\b':sb.append("\\b");break;//退格 | ||
| 25 | - case'\f':sb.append("\\f");break;//走纸换页 | ||
| 26 | - case'\n':sb.append("\\n");break;//换行 | ||
| 27 | - case'\r':sb.append("\\r");break;//回车 | ||
| 28 | - case'\t':sb.append("\\t");break;//横向跳格 | ||
| 29 | - default: sb.append(c); | ||
| 30 | - }} | ||
| 31 | - return sb.toString(); | ||
| 32 | - } | ||
| 33 | - | ||
| 34 | - public static String stringToJson(String s){ | ||
| 35 | - String resString=""; | ||
| 36 | - if(!TextUtils.isEmpty(s)&&s.length()>2) { | ||
| 37 | - String temp = s.replace("\\", ""); | ||
| 38 | - resString = temp.substring(1, temp.length() - 1); | ||
| 39 | - } | ||
| 40 | - return resString; | ||
| 41 | - } | ||
| 42 | - /*判断url*/ | ||
| 43 | - public static void judgeUrl(String url){ | ||
| 44 | - if (url == null) | ||
| 45 | - return; | ||
| 46 | - | ||
| 47 | - // rtmp:// | ||
| 48 | - if (url.length() < 8) { | ||
| 49 | - Log.e(TAG, "Input publish url error:" + url); | ||
| 50 | - return; | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - if (!url.startsWith("rtmp://")) { | ||
| 54 | - Log.e(TAG, "Input publish url error:" + url); | ||
| 55 | - return; | ||
| 56 | - } | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - /** | ||
| 60 | - * 时间 | ||
| 61 | - * @param currentTime | ||
| 62 | - * @return | ||
| 63 | - */ | ||
| 64 | - private String generateTime(long currentTime) { | ||
| 65 | - int totalSeconds = (int) (currentTime); | ||
| 66 | - | ||
| 67 | - int seconds = totalSeconds % 60; | ||
| 68 | - int minutes = (totalSeconds / 60) % 60; | ||
| 69 | - int hours = totalSeconds / 3600; | ||
| 70 | - | ||
| 71 | - if (hours > 0) { | ||
| 72 | - return String.format(Locale.US, "%02d:%02d:%02d", hours, minutes, | ||
| 73 | - seconds).toString(); | ||
| 74 | - } else { | ||
| 75 | - return String.format(Locale.US, "%02d:%02d", minutes, seconds) | ||
| 76 | - .toString(); | ||
| 77 | - } | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - public static int dp2px(Context context, float dp) { | ||
| 81 | - return (int) Math.ceil(context.getResources().getDisplayMetrics().density * dp); | ||
| 82 | - } | ||
| 83 | -} | 1 | +package com.mang.xdy.utils; |
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.text.TextUtils; | ||
| 5 | +import android.util.Log; | ||
| 6 | + | ||
| 7 | +import java.util.Locale; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * Created by abao on 2017/3/30. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +public class XdyStringUtils { | ||
| 14 | + private static String TAG="xdysdk"; | ||
| 15 | + public static String stringToJson(String s,boolean isJSjson){ | ||
| 16 | + StringBuffer sb = new StringBuffer(); | ||
| 17 | + for(int i=0; i<s.length(); i++){ | ||
| 18 | + char c =s.charAt(i); | ||
| 19 | + switch(c){ | ||
| 20 | + case'\'': if(isJSjson) {sb.append("\\\'");}else{sb.append("\'");} break; | ||
| 21 | + case'\"': if(!isJSjson) {sb.append("\\\"");}else{sb.append("\"");} break; | ||
| 22 | + case'\\':sb.append("\\\\"); break; //如果不处理单引号,可以释放此段代码,若结合StringDanYinToJSON()处理单引号就必须注释掉该段代码 | ||
| 23 | + case'/': sb.append("\\/");break; | ||
| 24 | + case'\b':sb.append("\\b");break;//退格 | ||
| 25 | + case'\f':sb.append("\\f");break;//走纸换页 | ||
| 26 | + case'\n':sb.append("\\n");break;//换行 | ||
| 27 | + case'\r':sb.append("\\r");break;//回车 | ||
| 28 | + case'\t':sb.append("\\t");break;//横向跳格 | ||
| 29 | + default: sb.append(c); | ||
| 30 | + }} | ||
| 31 | + return sb.toString(); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public static String stringToJson(String s){ | ||
| 35 | + String resString=""; | ||
| 36 | + if(!TextUtils.isEmpty(s)&&s.length()>2) { | ||
| 37 | + String temp = s.replace("\\", ""); | ||
| 38 | + resString = temp.substring(1, temp.length() - 1); | ||
| 39 | + } | ||
| 40 | + return resString; | ||
| 41 | + } | ||
| 42 | + /*判断url*/ | ||
| 43 | + public static void judgeUrl(String url){ | ||
| 44 | + if (url == null) | ||
| 45 | + return; | ||
| 46 | + | ||
| 47 | + // rtmp:// | ||
| 48 | + if (url.length() < 8) { | ||
| 49 | + Log.e(TAG, "Input publish url error:" + url); | ||
| 50 | + return; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + if (!url.startsWith("rtmp://")) { | ||
| 54 | + Log.e(TAG, "Input publish url error:" + url); | ||
| 55 | + return; | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 时间 | ||
| 61 | + * @param currentTime | ||
| 62 | + * @return | ||
| 63 | + */ | ||
| 64 | + private String generateTime(long currentTime) { | ||
| 65 | + int totalSeconds = (int) (currentTime); | ||
| 66 | + | ||
| 67 | + int seconds = totalSeconds % 60; | ||
| 68 | + int minutes = (totalSeconds / 60) % 60; | ||
| 69 | + int hours = totalSeconds / 3600; | ||
| 70 | + | ||
| 71 | + if (hours > 0) { | ||
| 72 | + return String.format(Locale.US, "%02d:%02d:%02d", hours, minutes, | ||
| 73 | + seconds).toString(); | ||
| 74 | + } else { | ||
| 75 | + return String.format(Locale.US, "%02d:%02d", minutes, seconds) | ||
| 76 | + .toString(); | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public static int dp2px(Context context, float dp) { | ||
| 81 | + return (int) Math.ceil(context.getResources().getDisplayMetrics().density * dp); | ||
| 82 | + } | ||
| 83 | +} |
-
请 注册 或 登录 后发表评论