Commit e964d03e0d170da48d804423605ba422cba8c47c
1 parent
2f8fe45c
Exists in
yxb_dev
and in
1 other branch
no message
Showing
222 changed files
with
11254 additions
and
15 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 222 files displayed.
.idea/gradle.xml
| @@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
| 10 | <option value="$PROJECT_DIR$" /> | 10 | <option value="$PROJECT_DIR$" /> |
| 11 | <option value="$PROJECT_DIR$/app" /> | 11 | <option value="$PROJECT_DIR$/app" /> |
| 12 | <option value="$PROJECT_DIR$/mvpsdk" /> | 12 | <option value="$PROJECT_DIR$/mvpsdk" /> |
| 13 | + <option value="$PROJECT_DIR$/mychartlibrary" /> | ||
| 13 | <option value="$PROJECT_DIR$/processor" /> | 14 | <option value="$PROJECT_DIR$/processor" /> |
| 14 | <option value="$PROJECT_DIR$/roundedimageview-2.2.1" /> | 15 | <option value="$PROJECT_DIR$/roundedimageview-2.2.1" /> |
| 15 | </set> | 16 | </set> |
.idea/modules.xml
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | <modules> | 4 | <modules> |
| 5 | <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> | 5 | <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> |
| 6 | <module fileurl="file://$PROJECT_DIR$/mvpsdk/mvpsdk.iml" filepath="$PROJECT_DIR$/mvpsdk/mvpsdk.iml" /> | 6 | <module fileurl="file://$PROJECT_DIR$/mvpsdk/mvpsdk.iml" filepath="$PROJECT_DIR$/mvpsdk/mvpsdk.iml" /> |
| 7 | + <module fileurl="file://$PROJECT_DIR$/mychartlibrary/mychartlibrary.iml" filepath="$PROJECT_DIR$/mychartlibrary/mychartlibrary.iml" /> | ||
| 7 | <module fileurl="file://$PROJECT_DIR$/parentwork.iml" filepath="$PROJECT_DIR$/parentwork.iml" /> | 8 | <module fileurl="file://$PROJECT_DIR$/parentwork.iml" filepath="$PROJECT_DIR$/parentwork.iml" /> |
| 8 | <module fileurl="file://$PROJECT_DIR$/processor/processor.iml" filepath="$PROJECT_DIR$/processor/processor.iml" /> | 9 | <module fileurl="file://$PROJECT_DIR$/processor/processor.iml" filepath="$PROJECT_DIR$/processor/processor.iml" /> |
| 9 | <module fileurl="file://$PROJECT_DIR$/roundedimageview-2.2.1/roundedimageview-2.2.1.iml" filepath="$PROJECT_DIR$/roundedimageview-2.2.1/roundedimageview-2.2.1.iml" /> | 10 | <module fileurl="file://$PROJECT_DIR$/roundedimageview-2.2.1/roundedimageview-2.2.1.iml" filepath="$PROJECT_DIR$/roundedimageview-2.2.1/roundedimageview-2.2.1.iml" /> |
app/build.gradle
| @@ -81,11 +81,8 @@ greendao { | @@ -81,11 +81,8 @@ greendao { | ||
| 81 | schemaVersion 1//数据库版本升级 | 81 | schemaVersion 1//数据库版本升级 |
| 82 | } | 82 | } |
| 83 | dependencies { | 83 | dependencies { |
| 84 | - | ||
| 85 | implementation fileTree(include: ['*.jar'], dir: 'libs') | 84 | implementation fileTree(include: ['*.jar'], dir: 'libs') |
| 86 | - implementation 'com.android.support:appcompat-v7:26.1.0' | ||
| 87 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' | 85 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' |
| 88 | - implementation 'com.android.support:support-v4:26.1.0' | ||
| 89 | testImplementation 'junit:junit:4.12' | 86 | testImplementation 'junit:junit:4.12' |
| 90 | androidTestImplementation 'com.android.support.test:runner:1.0.1' | 87 | androidTestImplementation 'com.android.support.test:runner:1.0.1' |
| 91 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' | 88 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' |
| @@ -97,6 +94,19 @@ dependencies { | @@ -97,6 +94,19 @@ dependencies { | ||
| 97 | compile 'me.leolin:ShortcutBadger:1.1.19@aar' | 94 | compile 'me.leolin:ShortcutBadger:1.1.19@aar' |
| 98 | annotationProcessor 'com.google.dagger:dagger-compiler:2.12' | 95 | annotationProcessor 'com.google.dagger:dagger-compiler:2.12' |
| 99 | compile files('libs/processor.jar') | 96 | compile files('libs/processor.jar') |
| 100 | - | ||
| 101 | compile 'com.contrarywind:Android-PickerView:4.1.3' | 97 | compile 'com.contrarywind:Android-PickerView:4.1.3' |
| 102 | -} | ||
| 103 | \ No newline at end of file | 98 | \ No newline at end of file |
| 99 | + implementation files('libs/gesture-imageview.jar') | ||
| 100 | + implementation 'com.android.support:support-v4:27.1.0' | ||
| 101 | + implementation project(':mychartlibrary') | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +configurations.all { | ||
| 105 | + resolutionStrategy.eachDependency { DependencyResolveDetails details -> | ||
| 106 | + def requested = details.requested | ||
| 107 | + if (requested.group == 'com.android.support') { | ||
| 108 | + if (!requested.name.startsWith("multidex")) { | ||
| 109 | + details.useVersion '26.1.0' | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | +} |
No preview for this file type
app/libs/processor.jar
No preview for this file type
app/src/main/AndroidManifest.xml
| @@ -48,6 +48,7 @@ | @@ -48,6 +48,7 @@ | ||
| 48 | <!-- 接收 SDK 消息广播权限, 第三方 APP 接入时,请将 com.netease.nim.demo 替换为自己的包名 --> | 48 | <!-- 接收 SDK 消息广播权限, 第三方 APP 接入时,请将 com.netease.nim.demo 替换为自己的包名 --> |
| 49 | <uses-permission android:name="com.shunzhi.parent.permission.RECEIVE_MSG" /> | 49 | <uses-permission android:name="com.shunzhi.parent.permission.RECEIVE_MSG" /> |
| 50 | <uses-permission android:name="android.permission.CALL_PHONE" /> | 50 | <uses-permission android:name="android.permission.CALL_PHONE" /> |
| 51 | + <uses-permission android:name="android.permission.RECORD_AUDIO" /> | ||
| 51 | 52 | ||
| 52 | <application | 53 | <application |
| 53 | android:name=".AppContext" | 54 | android:name=".AppContext" |
| @@ -117,7 +118,6 @@ | @@ -117,7 +118,6 @@ | ||
| 117 | android:name="com.amap.api.v2.apikey" | 118 | android:name="com.amap.api.v2.apikey" |
| 118 | android:value="1d130afb822d8a1019e6592cbaf10bcc" /> | 119 | android:value="1d130afb822d8a1019e6592cbaf10bcc" /> |
| 119 | 120 | ||
| 120 | - | ||
| 121 | <provider | 121 | <provider |
| 122 | android:name="android.support.v4.content.FileProvider" | 122 | android:name="android.support.v4.content.FileProvider" |
| 123 | android:authorities="com.shunzhi.parent.fileprovider" | 123 | android:authorities="com.shunzhi.parent.fileprovider" |
| @@ -147,6 +147,12 @@ | @@ -147,6 +147,12 @@ | ||
| 147 | <!-- android:screenOrientation="portrait" --> | 147 | <!-- android:screenOrientation="portrait" --> |
| 148 | <!-- android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> --> | 148 | <!-- android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> --> |
| 149 | <activity | 149 | <activity |
| 150 | + android:name=".ui.activity.chartroom.RecyclerViewChatActivity" | ||
| 151 | + android:theme="@style/AppBarTheme" | ||
| 152 | + android:windowSoftInputMode="adjustResize|stateHidden" | ||
| 153 | + android:screenOrientation="portrait" | ||
| 154 | + /> | ||
| 155 | + <activity | ||
| 150 | android:name=".ui.activity.MyChildActivity" | 156 | android:name=".ui.activity.MyChildActivity" |
| 151 | android:screenOrientation="portrait" /> | 157 | android:screenOrientation="portrait" /> |
| 152 | <activity | 158 | <activity |
| @@ -178,6 +184,11 @@ | @@ -178,6 +184,11 @@ | ||
| 178 | android:launchMode="singleInstance" | 184 | android:launchMode="singleInstance" |
| 179 | android:screenOrientation="portrait" | 185 | android:screenOrientation="portrait" |
| 180 | android:windowSoftInputMode="adjustPan|stateHidden" /> | 186 | android:windowSoftInputMode="adjustPan|stateHidden" /> |
| 187 | + | ||
| 188 | + <activity android:name=".ui.activity.chartroom.ImageViewActivity" | ||
| 189 | + android:launchMode="singleInstance" | ||
| 190 | + android:screenOrientation="portrait" | ||
| 191 | + android:windowSoftInputMode="adjustPan|stateHidden"/> | ||
| 181 | <activity | 192 | <activity |
| 182 | android:name=".ui.activity.binding.CheckInfoActivity" | 193 | android:name=".ui.activity.binding.CheckInfoActivity" |
| 183 | android:launchMode="singleInstance" | 194 | android:launchMode="singleInstance" |
| @@ -212,21 +223,20 @@ | @@ -212,21 +223,20 @@ | ||
| 212 | android:name=".ui.activity.BankActivity" | 223 | android:name=".ui.activity.BankActivity" |
| 213 | android:launchMode="singleInstance" | 224 | android:launchMode="singleInstance" |
| 214 | android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> | 225 | android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> |
| 215 | - | ||
| 216 | <activity | 226 | <activity |
| 217 | android:name=".ui.activity.apply.ApplyReplaceCardActivity" | 227 | android:name=".ui.activity.apply.ApplyReplaceCardActivity" |
| 218 | android:launchMode="singleInstance" | 228 | android:launchMode="singleInstance" |
| 219 | android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> | 229 | android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> |
| 220 | - | ||
| 221 | <activity | 230 | <activity |
| 222 | android:name=".ui.activity.apply.ApplySigninActivity" | 231 | android:name=".ui.activity.apply.ApplySigninActivity" |
| 223 | android:launchMode="singleInstance" /> | 232 | android:launchMode="singleInstance" /> |
| 224 | 233 | ||
| 225 | <service | 234 | <service |
| 226 | android:name=".ui.service.BadgeIntentService" | 235 | android:name=".ui.service.BadgeIntentService" |
| 227 | - android:exported="false"></service> | 236 | + android:exported="false" /> |
| 228 | 237 | ||
| 229 | - <activity android:name=".ui.activity.message.MesageActivity"></activity> | 238 | + <activity android:name=".ui.activity.message.MesageActivity" /> |
| 239 | + <activity android:name=".ui.activity.message.LeaverMessagesActivity"></activity> | ||
| 230 | </application> | 240 | </application> |
| 231 | 241 | ||
| 232 | </manifest> | 242 | </manifest> |
| 233 | \ No newline at end of file | 243 | \ No newline at end of file |
app/src/main/java/com/shunzhi/parent/AppContext.java
| @@ -5,7 +5,6 @@ import android.content.Context; | @@ -5,7 +5,6 @@ import android.content.Context; | ||
| 5 | import android.content.Intent; | 5 | import android.content.Intent; |
| 6 | import android.content.SharedPreferences; | 6 | import android.content.SharedPreferences; |
| 7 | import android.text.TextUtils; | 7 | import android.text.TextUtils; |
| 8 | -import android.util.Log; | ||
| 9 | 8 | ||
| 10 | import com.amap.api.location.AMapLocation; | 9 | import com.amap.api.location.AMapLocation; |
| 11 | import com.amap.api.location.AMapLocationClient; | 10 | import com.amap.api.location.AMapLocationClient; |
| @@ -18,6 +17,7 @@ import com.netease.nimlib.sdk.StatusBarNotificationConfig; | @@ -18,6 +17,7 @@ import com.netease.nimlib.sdk.StatusBarNotificationConfig; | ||
| 18 | import com.netease.nimlib.sdk.auth.LoginInfo; | 17 | import com.netease.nimlib.sdk.auth.LoginInfo; |
| 19 | import com.share.mvpsdk.global.GlobalApplication; | 18 | import com.share.mvpsdk.global.GlobalApplication; |
| 20 | import com.share.mvpsdk.helper.RetrofitCreateHelper; | 19 | import com.share.mvpsdk.helper.RetrofitCreateHelper; |
| 20 | +import com.shunzhi.mychartlibrary.db.BaseManager; | ||
| 21 | import com.shunzhi.parent.bean.message.DaoMaster; | 21 | import com.shunzhi.parent.bean.message.DaoMaster; |
| 22 | import com.shunzhi.parent.bean.message.DaoSession; | 22 | import com.shunzhi.parent.bean.message.DaoSession; |
| 23 | import com.shunzhi.parent.dbhelper.GreenDaoDatabaseOpenHelper; | 23 | import com.shunzhi.parent.dbhelper.GreenDaoDatabaseOpenHelper; |
| @@ -70,7 +70,7 @@ public class AppContext extends GlobalApplication { | @@ -70,7 +70,7 @@ public class AppContext extends GlobalApplication { | ||
| 70 | NIMClient.init(this, loginInfo(), options()); | 70 | NIMClient.init(this, loginInfo(), options()); |
| 71 | if (null==AppConfig.getAppConfig(getContext()).get(AppConfig.DISTRICT)) | 71 | if (null==AppConfig.getAppConfig(getContext()).get(AppConfig.DISTRICT)) |
| 72 | AppConfig.getAppConfig(getContext()).set(AppConfig.DISTRICT,"越城区"); | 72 | AppConfig.getAppConfig(getContext()).set(AppConfig.DISTRICT,"越城区"); |
| 73 | - | 73 | + BaseManager.initOpenHelper(this); |
| 74 | if (inMainProcess(this)) { | 74 | if (inMainProcess(this)) { |
| 75 | //开启地图地位 | 75 | //开启地图地位 |
| 76 | initMapLocal(); | 76 | initMapLocal(); |
app/src/main/java/com/shunzhi/parent/api/GetLeaveMessageListAPI.java
0 → 100644
| @@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
| 1 | +package com.shunzhi.parent.api; | ||
| 2 | + | ||
| 3 | +import com.google.gson.JsonObject; | ||
| 4 | + | ||
| 5 | +import io.reactivex.Observable; | ||
| 6 | +import retrofit2.http.GET; | ||
| 7 | +import retrofit2.http.Query; | ||
| 8 | + | ||
| 9 | +public interface GetLeaveMessageListAPI { | ||
| 10 | + | ||
| 11 | + @GET("api/XAWebCommon/GetLeaveMessageList") | ||
| 12 | + Observable<JsonObject> GetLeaveMessageList(@Query("puserid") String puserid,@Query("suserid")String suserid); | ||
| 13 | + | ||
| 14 | +} |
app/src/main/java/com/shunzhi/parent/contract/leavermessage/LeaverMessage.java
0 → 100644
| @@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
| 1 | +package com.shunzhi.parent.contract.leavermessage; | ||
| 2 | + | ||
| 3 | +public class LeaverMessage { | ||
| 4 | + | ||
| 5 | + public String id; | ||
| 6 | + | ||
| 7 | + public String sendUserId; | ||
| 8 | + | ||
| 9 | + public String receiveUserId; | ||
| 10 | + | ||
| 11 | + public String content; | ||
| 12 | + | ||
| 13 | + public String isRead; | ||
| 14 | + | ||
| 15 | + public String isRecall; | ||
| 16 | + | ||
| 17 | + public String intime; | ||
| 18 | + | ||
| 19 | + public String type; | ||
| 20 | + | ||
| 21 | + @Override | ||
| 22 | + public String toString() { | ||
| 23 | + return "LeaverMessage{" + | ||
| 24 | + "id='" + id + '\'' + | ||
| 25 | + ", sendUserId='" + sendUserId + '\'' + | ||
| 26 | + ", receiveUserId='" + receiveUserId + '\'' + | ||
| 27 | + ", content='" + content + '\'' + | ||
| 28 | + ", isRead='" + isRead + '\'' + | ||
| 29 | + ", isRecall='" + isRecall + '\'' + | ||
| 30 | + ", intime='" + intime + '\'' + | ||
| 31 | + ", type='" + type + '\'' + | ||
| 32 | + '}'; | ||
| 33 | + } | ||
| 34 | +} |
app/src/main/java/com/shunzhi/parent/contract/leavermessage/LeaverMessageContract.java
0 → 100644
| @@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
| 1 | +package com.shunzhi.parent.contract.leavermessage; | ||
| 2 | + | ||
| 3 | +import com.google.gson.JsonObject; | ||
| 4 | +import com.share.mvpsdk.base.BasePresenter; | ||
| 5 | +import com.share.mvpsdk.base.IBaseActivity; | ||
| 6 | +import com.share.mvpsdk.base.IBaseModel; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +import io.reactivex.Observable; | ||
| 11 | + | ||
| 12 | +public interface LeaverMessageContract { | ||
| 13 | + | ||
| 14 | + public abstract class MyLeaverMessagePresenter extends BasePresenter<ILeaverMessageModel,ILeverMessageView>{ | ||
| 15 | + | ||
| 16 | + public abstract void GetLeaveMessageList(String puserid,String suserid); | ||
| 17 | + | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + interface ILeaverMessageModel extends IBaseModel { | ||
| 21 | + | ||
| 22 | + Observable<JsonObject> GetLeaveMessageList(String puserid, String suserid); | ||
| 23 | + | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + interface ILeverMessageView extends IBaseActivity{ | ||
| 27 | + | ||
| 28 | + abstract void ShowLeaverMessageList(List<LeaverMessage> leaverMessageList); | ||
| 29 | + | ||
| 30 | + } | ||
| 31 | +} |
app/src/main/java/com/shunzhi/parent/model/leavermessage/LeaverMessageModel.java
0 → 100644
| @@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
| 1 | +package com.shunzhi.parent.model.leavermessage; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.google.gson.JsonObject; | ||
| 5 | +import com.share.mvpsdk.helper.RetrofitCreateHelper; | ||
| 6 | +import com.share.mvpsdk.helper.RxHelper; | ||
| 7 | +import com.shunzhi.parent.AppConfig; | ||
| 8 | +import com.shunzhi.parent.api.GetLeaveMessageListAPI; | ||
| 9 | +import com.shunzhi.parent.contract.leavermessage.LeaverMessageContract; | ||
| 10 | + | ||
| 11 | +import io.reactivex.Observable; | ||
| 12 | + | ||
| 13 | +public class LeaverMessageModel implements LeaverMessageContract.ILeaverMessageModel{ | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + @Override | ||
| 17 | + public Observable GetLeaveMessageList(String puserid, String suserid) { | ||
| 18 | + return RetrofitCreateHelper.getInstance().createApi(GetLeaveMessageListAPI.class, AppConfig.BASE_URL) | ||
| 19 | + .GetLeaveMessageList(puserid,suserid).compose(RxHelper.<JsonObject>rxSchedulerHelper()); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + public static LeaverMessageContract.ILeaverMessageModel newInstance() { | ||
| 23 | + return new LeaverMessageModel(); | ||
| 24 | + } | ||
| 25 | +} |
app/src/main/java/com/shunzhi/parent/presenter/leavermessage/LeaverMessagePresenter.java
0 → 100644
| @@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
| 1 | +package com.shunzhi.parent.presenter.leavermessage; | ||
| 2 | + | ||
| 3 | +import com.share.mvpsdk.base.BasePresenter; | ||
| 4 | +import com.shunzhi.parent.contract.leavermessage.LeaverMessageContract; | ||
| 5 | +import com.shunzhi.parent.model.leavermessage.LeaverMessageModel; | ||
| 6 | + | ||
| 7 | +public class LeaverMessagePresenter extends LeaverMessageContract.MyLeaverMessagePresenter{ | ||
| 8 | + @Override | ||
| 9 | + public LeaverMessageContract.ILeaverMessageModel getModel() { | ||
| 10 | + return LeaverMessageModel.newInstance(); | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + @Override | ||
| 14 | + public void onStart() { | ||
| 15 | + | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + @Override | ||
| 19 | + public void GetLeaveMessageList(String puserid, String suserid) { | ||
| 20 | + | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public static BasePresenter newInstance() { | ||
| 24 | + return new LeaverMessagePresenter(); | ||
| 25 | + } | ||
| 26 | +} |
app/src/main/java/com/shunzhi/parent/ui/activity/chartroom/ImageViewActivity.java
0 → 100644
| @@ -0,0 +1,116 @@ | @@ -0,0 +1,116 @@ | ||
| 1 | +package com.shunzhi.parent.ui.activity.chartroom; | ||
| 2 | + | ||
| 3 | +import android.content.Intent; | ||
| 4 | +import android.os.Bundle; | ||
| 5 | +import android.support.v4.app.Fragment; | ||
| 6 | +import android.support.v4.app.FragmentActivity; | ||
| 7 | +import android.support.v4.app.FragmentManager; | ||
| 8 | +import android.support.v4.app.FragmentPagerAdapter; | ||
| 9 | +import android.support.v4.view.ViewPager; | ||
| 10 | +import android.support.v4.view.ViewPager.OnPageChangeListener; | ||
| 11 | +import android.widget.TextView; | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +import com.shunzhi.parent.R; | ||
| 15 | +import com.shunzhi.parent.ui.activity.chartroom.fragment.ImageViewFragment; | ||
| 16 | + | ||
| 17 | +import java.util.ArrayList; | ||
| 18 | +import java.util.List; | ||
| 19 | + | ||
| 20 | +public class ImageViewActivity extends FragmentActivity { | ||
| 21 | + private ArrayList<String> imageList; | ||
| 22 | + private List<Fragment> fragList; | ||
| 23 | + private ViewPager imageVp; | ||
| 24 | + private TextView currentTv; | ||
| 25 | + private TextView totalTv; | ||
| 26 | + private int currentPage; | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + protected void onCreate(Bundle savedInstanceState) { | ||
| 30 | + super.onCreate(savedInstanceState); | ||
| 31 | + Intent intent = getIntent(); | ||
| 32 | + Bundle bundle = intent.getExtras(); | ||
| 33 | + if (bundle != null) { | ||
| 34 | + if (bundle.containsKey("images")) { | ||
| 35 | + imageList = bundle.getStringArrayList("images"); | ||
| 36 | + } | ||
| 37 | + if (bundle.containsKey("clickedIndex")) { | ||
| 38 | + currentPage = bundle.getInt("clickedIndex"); | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + setContentView(R.layout.activity_images_view); | ||
| 42 | + findView(); | ||
| 43 | + init(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + private void init() { | ||
| 47 | + totalTv.setText("/" + imageList.size()); | ||
| 48 | + fragList = new ArrayList<Fragment>(); | ||
| 49 | + for (int i = 0; i < imageList.size(); i++) { | ||
| 50 | + ImageViewFragment imageVF = new ImageViewFragment(); | ||
| 51 | + imageVF.setImageUrl(imageList.get(i)); | ||
| 52 | + fragList.add(imageVF); | ||
| 53 | + } | ||
| 54 | + // 类似缓存 | ||
| 55 | + imageVp.setOffscreenPageLimit(imageList.size()); | ||
| 56 | + imageVp.setAdapter(new ImageViewFPAdapter(getSupportFragmentManager())); | ||
| 57 | + imageVp.setOnPageChangeListener(new OnPageChangeListener() { | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public void onPageSelected(int index) { | ||
| 61 | + currentPage = index; | ||
| 62 | + currentTv.setText((index + 1) + ""); | ||
| 63 | + fragList.get(currentPage).onPause(); // 调用切换前Fargment的onPause() | ||
| 64 | + if (fragList.get(index).isAdded()) { | ||
| 65 | + fragList.get(index).onResume(); // 调用切换后Fargment的onResume() | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Override | ||
| 70 | + public void onPageScrolled(int arg0, float arg1, int arg2) { | ||
| 71 | + | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public void onPageScrollStateChanged(int arg0) { | ||
| 76 | + | ||
| 77 | + } | ||
| 78 | + }); | ||
| 79 | + imageVp.setCurrentItem(currentPage); | ||
| 80 | + currentTv.setText((currentPage + 1) + ""); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + protected void findView() { | ||
| 84 | + imageVp = (ViewPager) findViewById(R.id.images_vp); | ||
| 85 | + currentTv = (TextView) findViewById(R.id.imageView_current_tv); | ||
| 86 | + totalTv = (TextView) findViewById(R.id.imageView_total_tv); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + class ImageViewFPAdapter extends FragmentPagerAdapter { | ||
| 90 | + protected FragmentManager fm; | ||
| 91 | + | ||
| 92 | + public ImageViewFPAdapter(FragmentManager fm) { | ||
| 93 | + super(fm); | ||
| 94 | + this.fm = fm; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + @Override | ||
| 98 | + public Fragment getItem(int arg0) { | ||
| 99 | + return fragList.get(arg0); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + @Override | ||
| 103 | + public int getCount() { | ||
| 104 | + return fragList.size(); | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @Override | ||
| 109 | + protected void onDestroy() { | ||
| 110 | + if (fragList.size() > 0) { | ||
| 111 | + for (Fragment fragment : fragList) | ||
| 112 | + fragment.onDestroy(); | ||
| 113 | + } | ||
| 114 | + super.onDestroy(); | ||
| 115 | + } | ||
| 116 | +} |
app/src/main/java/com/shunzhi/parent/ui/activity/chartroom/RecyclerViewChatActivity.java
0 → 100644
| @@ -0,0 +1,442 @@ | @@ -0,0 +1,442 @@ | ||
| 1 | +package com.shunzhi.parent.ui.activity.chartroom; | ||
| 2 | + | ||
| 3 | +import android.graphics.Rect; | ||
| 4 | +import android.os.Bundle; | ||
| 5 | +import android.os.Handler; | ||
| 6 | +import android.os.Message; | ||
| 7 | +import android.support.v7.widget.LinearLayoutManager; | ||
| 8 | +import android.support.v7.widget.RecyclerView; | ||
| 9 | +import android.view.View; | ||
| 10 | +import android.view.ViewTreeObserver; | ||
| 11 | + | ||
| 12 | +import com.shunzhi.mychartlibrary.BaseActivity; | ||
| 13 | +import com.shunzhi.mychartlibrary.db.ChatMessageBean; | ||
| 14 | +import com.shunzhi.parent.ui.activity.chartroom.adapter.ChatListViewAdapter; | ||
| 15 | +import com.shunzhi.parent.ui.activity.chartroom.adapter.ChatRecyclerAdapter; | ||
| 16 | +import com.shunzhi.mychartlibrary.animator.SlideInOutBottomItemAnimator; | ||
| 17 | +import com.shunzhi.mychartlibrary.common.ChatConst; | ||
| 18 | +import com.shunzhi.mychartlibrary.utils.KeyBoardUtils; | ||
| 19 | +import com.shunzhi.mychartlibrary.widget.AudioRecordButton; | ||
| 20 | +import com.shunzhi.mychartlibrary.widget.pulltorefresh.PullToRefreshRecyclerView; | ||
| 21 | +import com.shunzhi.mychartlibrary.widget.pulltorefresh.WrapContentLinearLayoutManager; | ||
| 22 | +import com.shunzhi.mychartlibrary.widget.pulltorefresh.base.PullToRefreshView; | ||
| 23 | + | ||
| 24 | +import java.lang.ref.WeakReference; | ||
| 25 | + | ||
| 26 | +public class RecyclerViewChatActivity extends BaseActivity { | ||
| 27 | + private PullToRefreshRecyclerView myList; | ||
| 28 | + private ChatRecyclerAdapter tbAdapter; | ||
| 29 | + private SendMessageHandler sendMessageHandler; | ||
| 30 | + private WrapContentLinearLayoutManager wcLinearLayoutManger; | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + protected void onCreate(Bundle savedInstanceState) { | ||
| 34 | + super.onCreate(savedInstanceState); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + protected void findView() { | ||
| 39 | + super.findView(); | ||
| 40 | + pullList.setSlideView(new PullToRefreshView(this).getSlideView(PullToRefreshView.RECYCLERVIEW)); | ||
| 41 | + myList = (PullToRefreshRecyclerView) pullList.returnMylist(); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + protected void onResume() { | ||
| 46 | + // TODO Auto-generated method stub | ||
| 47 | + super.onResume(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + protected void onDestroy() { | ||
| 52 | + tblist.clear(); | ||
| 53 | + tbAdapter.notifyDataSetChanged(); | ||
| 54 | + myList.setAdapter(null); | ||
| 55 | + sendMessageHandler.removeCallbacksAndMessages(null); | ||
| 56 | + super.onDestroy(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + protected void init() { | ||
| 61 | + setTitle(getIntent().getStringExtra("childName")); | ||
| 62 | + tbAdapter = new ChatRecyclerAdapter(this, tblist,getIntent().getStringExtra("childPhoto")); | ||
| 63 | + wcLinearLayoutManger = new WrapContentLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); | ||
| 64 | + myList.setLayoutManager(wcLinearLayoutManger); | ||
| 65 | + myList.setItemAnimator(new SlideInOutBottomItemAnimator(myList)); | ||
| 66 | + myList.setAdapter(tbAdapter); | ||
| 67 | + sendMessageHandler = new SendMessageHandler(this); | ||
| 68 | + tbAdapter.isPicRefresh = true; | ||
| 69 | + tbAdapter.notifyDataSetChanged(); | ||
| 70 | + tbAdapter.setSendErrorListener(new ChatRecyclerAdapter.SendErrorListener() { | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public void onClick(int position) { | ||
| 74 | + // TODO Auto-generated method stub | ||
| 75 | + ChatMessageBean tbub = tblist.get(position); | ||
| 76 | + if (tbub.getType() == ChatRecyclerAdapter.TO_USER_VOICE) { | ||
| 77 | + sendVoice(tbub.getUserVoiceTime(), tbub.getUserVoicePath()); | ||
| 78 | + tblist.remove(position); | ||
| 79 | + } else if (tbub.getType() == ChatRecyclerAdapter.TO_USER_IMG) { | ||
| 80 | + sendImage(tbub.getImageLocal()); | ||
| 81 | + tblist.remove(position); | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + }); | ||
| 86 | + tbAdapter.setVoiceIsReadListener(new ChatRecyclerAdapter.VoiceIsRead() { | ||
| 87 | + | ||
| 88 | + @Override | ||
| 89 | + public void voiceOnClick(int position) { | ||
| 90 | + // TODO Auto-generated method stub | ||
| 91 | + for (int i = 0; i < tbAdapter.unReadPosition.size(); i++) { | ||
| 92 | + if (tbAdapter.unReadPosition.get(i).equals(position + "")) { | ||
| 93 | + tbAdapter.unReadPosition.remove(i); | ||
| 94 | + break; | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + }); | ||
| 100 | + voiceBtn.setAudioFinishRecorderListener(new AudioRecordButton.AudioFinishRecorderListener() { | ||
| 101 | + | ||
| 102 | + @Override | ||
| 103 | + public void onFinished(float seconds, String filePath) { | ||
| 104 | + // TODO Auto-generated method stub | ||
| 105 | + sendVoice(seconds, filePath); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @Override | ||
| 109 | + public void onStart() { | ||
| 110 | + // TODO Auto-generated method stub | ||
| 111 | + tbAdapter.stopPlayVoice(); | ||
| 112 | + } | ||
| 113 | + }); | ||
| 114 | + myList.setOnScrollListener(new RecyclerView.OnScrollListener() { | ||
| 115 | + | ||
| 116 | + @Override | ||
| 117 | + public void onScrollStateChanged(RecyclerView view, int scrollState) { | ||
| 118 | + // TODO Auto-generated method stub | ||
| 119 | + switch (scrollState) { | ||
| 120 | + case RecyclerView.SCROLL_STATE_IDLE: | ||
| 121 | + tbAdapter.handler.removeCallbacksAndMessages(null); | ||
| 122 | + tbAdapter.setIsGif(true); | ||
| 123 | + tbAdapter.isPicRefresh = false; | ||
| 124 | + tbAdapter.notifyDataSetChanged(); | ||
| 125 | + break; | ||
| 126 | + case RecyclerView.SCROLL_STATE_DRAGGING: | ||
| 127 | + tbAdapter.handler.removeCallbacksAndMessages(null); | ||
| 128 | + tbAdapter.setIsGif(false); | ||
| 129 | + tbAdapter.isPicRefresh = true; | ||
| 130 | + reset(); | ||
| 131 | + KeyBoardUtils.hideKeyBoard(RecyclerViewChatActivity.this, | ||
| 132 | + mEditTextContent); | ||
| 133 | + break; | ||
| 134 | + default: | ||
| 135 | + break; | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + @Override | ||
| 140 | + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | ||
| 141 | + super.onScrolled(recyclerView, dx, dy); | ||
| 142 | + } | ||
| 143 | + }); | ||
| 144 | + controlKeyboardLayout(activityRootView, pullList); | ||
| 145 | + super.init(); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + /** | ||
| 149 | + * @param root 最外层布局 | ||
| 150 | + * @param needToScrollView 要滚动的布局,就是说在键盘弹出的时候,你需要试图滚动上去的View,在键盘隐藏的时候,他又会滚动到原来的位置的布局 | ||
| 151 | + */ | ||
| 152 | + private void controlKeyboardLayout(final View root, final View needToScrollView) { | ||
| 153 | + root.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { | ||
| 154 | + | ||
| 155 | + private Rect r = new Rect(); | ||
| 156 | + | ||
| 157 | + @Override | ||
| 158 | + public void onGlobalLayout() { | ||
| 159 | + //获取当前界面可视部分 | ||
| 160 | + RecyclerViewChatActivity.this.getWindow().getDecorView().getWindowVisibleDisplayFrame(r); | ||
| 161 | + //获取屏幕的高度 | ||
| 162 | + int screenHeight = RecyclerViewChatActivity.this.getWindow().getDecorView().getRootView().getHeight(); | ||
| 163 | + //此处就是用来获取键盘的高度的, 在键盘没有弹出的时候 此高度为0 键盘弹出的时候为一个正数 | ||
| 164 | + int heightDifference = screenHeight - r.bottom; | ||
| 165 | + int recyclerHeight = 0; | ||
| 166 | + if (wcLinearLayoutManger != null) { | ||
| 167 | + recyclerHeight = wcLinearLayoutManger.getRecyclerHeight(); | ||
| 168 | + } | ||
| 169 | + if (heightDifference == 0 || heightDifference == bottomStatusHeight) { | ||
| 170 | + needToScrollView.scrollTo(0, 0); | ||
| 171 | + } else { | ||
| 172 | + if (heightDifference < recyclerHeight) { | ||
| 173 | + int contentHeight = wcLinearLayoutManger == null ? 0 : wcLinearLayoutManger.getHeight(); | ||
| 174 | + if (recyclerHeight < contentHeight) { | ||
| 175 | + listSlideHeight = heightDifference - (contentHeight - recyclerHeight); | ||
| 176 | + needToScrollView.scrollTo(0, listSlideHeight); | ||
| 177 | + } else { | ||
| 178 | + listSlideHeight = heightDifference; | ||
| 179 | + needToScrollView.scrollTo(0, listSlideHeight); | ||
| 180 | + } | ||
| 181 | + } else { | ||
| 182 | + listSlideHeight = 0; | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + } | ||
| 186 | + }); | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + @Override | ||
| 190 | + protected void loadRecords() { | ||
| 191 | + isDown = true; | ||
| 192 | + if (pagelist != null) { | ||
| 193 | + pagelist.clear(); | ||
| 194 | + } | ||
| 195 | + pagelist = mChatDbManager.loadPages(page, number); | ||
| 196 | + position = pagelist.size(); | ||
| 197 | + if (pagelist.size() != 0) { | ||
| 198 | + pagelist.addAll(tblist); | ||
| 199 | + tblist.clear(); | ||
| 200 | + tblist.addAll(pagelist); | ||
| 201 | + if (imageList != null) { | ||
| 202 | + imageList.clear(); | ||
| 203 | + } | ||
| 204 | + if (imagePosition != null) { | ||
| 205 | + imagePosition.clear(); | ||
| 206 | + } | ||
| 207 | + int key = 0; | ||
| 208 | + int position = 0; | ||
| 209 | + for (ChatMessageBean cmb : tblist) { | ||
| 210 | + if (cmb.getType() == ChatListViewAdapter.FROM_USER_IMG || cmb.getType() == ChatListViewAdapter.TO_USER_IMG) { | ||
| 211 | + imageList.add(cmb.getImageLocal()); | ||
| 212 | + imagePosition.put(key, position); | ||
| 213 | + position++; | ||
| 214 | + } | ||
| 215 | + key++; | ||
| 216 | + } | ||
| 217 | + tbAdapter.setImageList(imageList); | ||
| 218 | + tbAdapter.setImagePosition(imagePosition); | ||
| 219 | + sendMessageHandler.sendEmptyMessage(PULL_TO_REFRESH_DOWN); | ||
| 220 | + if (page == 0) { | ||
| 221 | + pullList.refreshComplete(); | ||
| 222 | + pullList.setPullGone(); | ||
| 223 | + } else { | ||
| 224 | + page--; | ||
| 225 | + } | ||
| 226 | + } else { | ||
| 227 | + if (page == 0) { | ||
| 228 | + pullList.refreshComplete(); | ||
| 229 | + pullList.setPullGone(); | ||
| 230 | + } | ||
| 231 | + } | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + static class SendMessageHandler extends Handler { | ||
| 235 | + WeakReference<RecyclerViewChatActivity> mActivity; | ||
| 236 | + | ||
| 237 | + SendMessageHandler(RecyclerViewChatActivity activity) { | ||
| 238 | + mActivity = new WeakReference<RecyclerViewChatActivity>(activity); | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + @Override | ||
| 242 | + public void handleMessage(Message msg) { | ||
| 243 | + // TODO Auto-generated method stub | ||
| 244 | + RecyclerViewChatActivity theActivity = mActivity.get(); | ||
| 245 | + if (theActivity != null) { | ||
| 246 | + switch (msg.what) { | ||
| 247 | + case REFRESH: | ||
| 248 | + theActivity.tbAdapter.isPicRefresh = true; | ||
| 249 | + theActivity.tbAdapter.notifyDataSetChanged(); | ||
| 250 | + int position = theActivity.tbAdapter.getItemCount() - 1 < 0 ? 0 : theActivity.tbAdapter.getItemCount() - 1; | ||
| 251 | + theActivity.myList.smoothScrollToPosition(position); | ||
| 252 | + break; | ||
| 253 | + case SEND_OK: | ||
| 254 | + theActivity.mEditTextContent.setText(""); | ||
| 255 | + theActivity.tbAdapter.isPicRefresh = true; | ||
| 256 | + theActivity.tbAdapter.notifyItemInserted(theActivity.tblist | ||
| 257 | + .size() - 1); | ||
| 258 | + theActivity.myList.smoothScrollToPosition(theActivity.tbAdapter.getItemCount() - 1); | ||
| 259 | + break; | ||
| 260 | + case RECERIVE_OK: | ||
| 261 | + theActivity.tbAdapter.isPicRefresh = true; | ||
| 262 | + theActivity.tbAdapter.notifyItemInserted(theActivity.tblist | ||
| 263 | + .size() - 1); | ||
| 264 | + theActivity.myList.smoothScrollToPosition(theActivity.tbAdapter.getItemCount() - 1); | ||
| 265 | + break; | ||
| 266 | + case PULL_TO_REFRESH_DOWN: | ||
| 267 | + theActivity.pullList.refreshComplete(); | ||
| 268 | + theActivity.tbAdapter.notifyDataSetChanged(); | ||
| 269 | + theActivity.myList.smoothScrollToPosition(theActivity.position - 1); | ||
| 270 | + theActivity.isDown = false; | ||
| 271 | + break; | ||
| 272 | + default: | ||
| 273 | + break; | ||
| 274 | + } | ||
| 275 | + } | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + /** | ||
| 281 | + * 发送文字 | ||
| 282 | + */ | ||
| 283 | + @Override | ||
| 284 | + protected void sendMessage() { | ||
| 285 | + new Thread(new Runnable() { | ||
| 286 | + @Override | ||
| 287 | + public void run() { | ||
| 288 | + String content = mEditTextContent.getText().toString(); | ||
| 289 | + tblist.add(getTbub(userName, ChatListViewAdapter.TO_USER_MSG, content, null, null, | ||
| 290 | + null, null, null, 0f, ChatConst.COMPLETED)); | ||
| 291 | + sendMessageHandler.sendEmptyMessage(SEND_OK); | ||
| 292 | + RecyclerViewChatActivity.this.content = content; | ||
| 293 | + receriveHandler.sendEmptyMessageDelayed(0, 1000); | ||
| 294 | + } | ||
| 295 | + }).start(); | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + /** | ||
| 299 | + * 接收文字 | ||
| 300 | + */ | ||
| 301 | + String content = ""; | ||
| 302 | + | ||
| 303 | + private void receriveMsgText(final String content) { | ||
| 304 | + new Thread(new Runnable() { | ||
| 305 | + @Override | ||
| 306 | + public void run() { | ||
| 307 | + String message = "回复:" + content; | ||
| 308 | + ChatMessageBean tbub = new ChatMessageBean(); | ||
| 309 | + tbub.setUserName(userName); | ||
| 310 | + String time = returnTime(); | ||
| 311 | + tbub.setUserContent(message); | ||
| 312 | + tbub.setTime(time); | ||
| 313 | + tbub.setType(ChatListViewAdapter.FROM_USER_MSG); | ||
| 314 | + tblist.add(tbub); | ||
| 315 | + sendMessageHandler.sendEmptyMessage(RECERIVE_OK); | ||
| 316 | + mChatDbManager.insert(tbub); | ||
| 317 | + } | ||
| 318 | + }).start(); | ||
| 319 | + } | ||
| 320 | + | ||
| 321 | + /** | ||
| 322 | + * 发送图片 | ||
| 323 | + */ | ||
| 324 | + int i = 0; | ||
| 325 | + | ||
| 326 | + @Override | ||
| 327 | + protected void sendImage(final String filePath) { | ||
| 328 | + new Thread(new Runnable() { | ||
| 329 | + @Override | ||
| 330 | + public void run() { | ||
| 331 | + if (i == 0) { | ||
| 332 | + tblist.add(getTbub(userName, ChatListViewAdapter.TO_USER_IMG, null, null, null, filePath, null, null, | ||
| 333 | + 0f, ChatConst.SENDING)); | ||
| 334 | + } else if (i == 1) { | ||
| 335 | + tblist.add(getTbub(userName, ChatListViewAdapter.TO_USER_IMG, null, null, null, filePath, null, null, | ||
| 336 | + 0f, ChatConst.SENDERROR)); | ||
| 337 | + } else if (i == 2) { | ||
| 338 | + tblist.add(getTbub(userName, ChatListViewAdapter.TO_USER_IMG, null, null, null, filePath, null, null, | ||
| 339 | + 0f, ChatConst.COMPLETED)); | ||
| 340 | + i = -1; | ||
| 341 | + } | ||
| 342 | + imageList.add(tblist.get(tblist.size() - 1).getImageLocal()); | ||
| 343 | + imagePosition.put(tblist.size() - 1, imageList.size() - 1); | ||
| 344 | + sendMessageHandler.sendEmptyMessage(SEND_OK); | ||
| 345 | + RecyclerViewChatActivity.this.filePath = filePath; | ||
| 346 | + receriveHandler.sendEmptyMessageDelayed(1, 3000); | ||
| 347 | + i++; | ||
| 348 | + } | ||
| 349 | + }).start(); | ||
| 350 | + } | ||
| 351 | + | ||
| 352 | + /** | ||
| 353 | + * 接收图片 | ||
| 354 | + */ | ||
| 355 | + String filePath = ""; | ||
| 356 | + | ||
| 357 | + private void receriveImageText(final String filePath) { | ||
| 358 | + new Thread(new Runnable() { | ||
| 359 | + @Override | ||
| 360 | + public void run() { | ||
| 361 | + ChatMessageBean tbub = new ChatMessageBean(); | ||
| 362 | + tbub.setUserName(userName); | ||
| 363 | + String time = returnTime(); | ||
| 364 | + tbub.setTime(time); | ||
| 365 | + tbub.setImageLocal(filePath); | ||
| 366 | + tbub.setType(ChatListViewAdapter.FROM_USER_IMG); | ||
| 367 | + tblist.add(tbub); | ||
| 368 | + imageList.add(tblist.get(tblist.size() - 1).getImageLocal()); | ||
| 369 | + imagePosition.put(tblist.size() - 1, imageList.size() - 1); | ||
| 370 | + sendMessageHandler.sendEmptyMessage(RECERIVE_OK); | ||
| 371 | + mChatDbManager.insert(tbub); | ||
| 372 | + } | ||
| 373 | + }).start(); | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | + /** | ||
| 377 | + * 发送语音 | ||
| 378 | + */ | ||
| 379 | + @Override | ||
| 380 | + protected void sendVoice(final float seconds, final String filePath) { | ||
| 381 | + new Thread(new Runnable() { | ||
| 382 | + @Override | ||
| 383 | + public void run() { | ||
| 384 | + tblist.add(getTbub(userName, ChatListViewAdapter.TO_USER_VOICE, null, null, null, null, filePath, | ||
| 385 | + null, seconds, ChatConst.SENDING)); | ||
| 386 | + sendMessageHandler.sendEmptyMessage(SEND_OK); | ||
| 387 | + RecyclerViewChatActivity.this.seconds = seconds; | ||
| 388 | + voiceFilePath = filePath; | ||
| 389 | + receriveHandler.sendEmptyMessageDelayed(2, 3000); | ||
| 390 | + } | ||
| 391 | + }).start(); | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | + /** | ||
| 395 | + * 接收语音 | ||
| 396 | + */ | ||
| 397 | + float seconds = 0.0f; | ||
| 398 | + String voiceFilePath = ""; | ||
| 399 | + | ||
| 400 | + private void receriveVoiceText(final float seconds, final String filePath) { | ||
| 401 | + new Thread(new Runnable() { | ||
| 402 | + @Override | ||
| 403 | + public void run() { | ||
| 404 | + ChatMessageBean tbub = new ChatMessageBean(); | ||
| 405 | + tbub.setUserName(userName); | ||
| 406 | + String time = returnTime(); | ||
| 407 | + tbub.setTime(time); | ||
| 408 | + tbub.setUserVoiceTime(seconds); | ||
| 409 | + tbub.setUserVoicePath(filePath); | ||
| 410 | + tbAdapter.unReadPosition.add(tblist.size() + ""); | ||
| 411 | + tbub.setType(ChatListViewAdapter.FROM_USER_VOICE); | ||
| 412 | + tblist.add(tbub); | ||
| 413 | + sendMessageHandler.sendEmptyMessage(RECERIVE_OK); | ||
| 414 | + mChatDbManager.insert(tbub); | ||
| 415 | + } | ||
| 416 | + }).start(); | ||
| 417 | + } | ||
| 418 | + | ||
| 419 | + /** | ||
| 420 | + * 为了模拟接收延迟 | ||
| 421 | + */ | ||
| 422 | + private Handler receriveHandler = new Handler() { | ||
| 423 | + @Override | ||
| 424 | + public void handleMessage(Message msg) { | ||
| 425 | + super.handleMessage(msg); | ||
| 426 | + switch (msg.what) { | ||
| 427 | + case 0: | ||
| 428 | + receriveMsgText(content); | ||
| 429 | + break; | ||
| 430 | + case 1: | ||
| 431 | + receriveImageText(filePath); | ||
| 432 | + break; | ||
| 433 | + case 2: | ||
| 434 | + receriveVoiceText(seconds, voiceFilePath); | ||
| 435 | + break; | ||
| 436 | + default: | ||
| 437 | + break; | ||
| 438 | + } | ||
| 439 | + } | ||
| 440 | + }; | ||
| 441 | + | ||
| 442 | +} |
app/src/main/java/com/shunzhi/parent/ui/activity/chartroom/adapter/ChatListViewAdapter.java
0 → 100644
| @@ -0,0 +1,826 @@ | @@ -0,0 +1,826 @@ | ||
| 1 | +package com.shunzhi.parent.ui.activity.chartroom.adapter; | ||
| 2 | + | ||
| 3 | +import android.annotation.SuppressLint; | ||
| 4 | +import android.app.Activity; | ||
| 5 | +import android.content.Context; | ||
| 6 | +import android.content.Intent; | ||
| 7 | +import android.graphics.drawable.AnimationDrawable; | ||
| 8 | +import android.media.MediaPlayer; | ||
| 9 | +import android.os.Handler; | ||
| 10 | +import android.os.Message; | ||
| 11 | +import android.util.DisplayMetrics; | ||
| 12 | +import android.view.LayoutInflater; | ||
| 13 | +import android.view.View; | ||
| 14 | +import android.view.ViewGroup; | ||
| 15 | +import android.view.WindowManager; | ||
| 16 | +import android.view.animation.Animation; | ||
| 17 | +import android.view.animation.AnimationUtils; | ||
| 18 | +import android.view.animation.LinearInterpolator; | ||
| 19 | +import android.widget.BaseAdapter; | ||
| 20 | +import android.widget.FrameLayout; | ||
| 21 | +import android.widget.ImageView; | ||
| 22 | +import android.widget.LinearLayout; | ||
| 23 | +import android.widget.TextView; | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +import com.shunzhi.mychartlibrary.db.ChatMessageBean; | ||
| 27 | +import com.shunzhi.parent.R; | ||
| 28 | +import com.shunzhi.parent.ui.activity.chartroom.ImageViewActivity; | ||
| 29 | +import com.shunzhi.mychartlibrary.common.ChatConst; | ||
| 30 | +import com.shunzhi.mychartlibrary.utils.FileSaveUtil; | ||
| 31 | +import com.shunzhi.mychartlibrary.utils.ImageCheckoutUtil; | ||
| 32 | +import com.shunzhi.mychartlibrary.widget.BubbleImageView; | ||
| 33 | +import com.shunzhi.mychartlibrary.widget.GifTextView; | ||
| 34 | +import com.shunzhi.mychartlibrary.widget.MediaManager; | ||
| 35 | + | ||
| 36 | +import java.io.File; | ||
| 37 | +import java.lang.ref.WeakReference; | ||
| 38 | +import java.math.BigDecimal; | ||
| 39 | +import java.text.DateFormat; | ||
| 40 | +import java.text.SimpleDateFormat; | ||
| 41 | +import java.util.ArrayList; | ||
| 42 | +import java.util.HashMap; | ||
| 43 | +import java.util.List; | ||
| 44 | + | ||
| 45 | +/** | ||
| 46 | + * Created by Mao Jiqing on 2016/9/28. | ||
| 47 | + */ | ||
| 48 | +public class ChatListViewAdapter extends BaseAdapter { | ||
| 49 | + private Context context; | ||
| 50 | + private List<ChatMessageBean> userList = new ArrayList<ChatMessageBean>(); | ||
| 51 | + private ArrayList<String> imageList = new ArrayList<String>(); | ||
| 52 | + private HashMap<Integer,Integer> imagePosition = new HashMap<Integer,Integer>(); | ||
| 53 | + public static final int FROM_USER_MSG = 0;//接收消息类型 | ||
| 54 | + public static final int TO_USER_MSG = 1;//发送消息类型 | ||
| 55 | + public static final int FROM_USER_IMG = 2;//接收消息类型 | ||
| 56 | + public static final int TO_USER_IMG = 3;//发送消息类型 | ||
| 57 | + public static final int FROM_USER_VOICE = 4;//接收消息类型 | ||
| 58 | + public static final int TO_USER_VOICE = 5;//发送消息类型 | ||
| 59 | + private int mMinItemWith;// 设置对话框的最大宽度和最小宽度 | ||
| 60 | + private int mMaxItemWith; | ||
| 61 | + public MyHandler handler; | ||
| 62 | + private Animation an; | ||
| 63 | + private SendErrorListener sendErrorListener; | ||
| 64 | + private VoiceIsRead voiceIsRead; | ||
| 65 | + public List<String> unReadPosition = new ArrayList<String>(); | ||
| 66 | + private int voicePlayPosition = -1; | ||
| 67 | + private LayoutInflater mLayoutInflater; | ||
| 68 | + private boolean isGif = true; | ||
| 69 | + public boolean isPicRefresh = true; | ||
| 70 | + | ||
| 71 | + public interface SendErrorListener { | ||
| 72 | + public void onClick(int position); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public void setSendErrorListener(SendErrorListener sendErrorListener) { | ||
| 76 | + this.sendErrorListener = sendErrorListener; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public interface VoiceIsRead { | ||
| 80 | + public void voiceOnClick(int position); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public void setVoiceIsReadListener(VoiceIsRead voiceIsRead) { | ||
| 84 | + this.voiceIsRead = voiceIsRead; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public ChatListViewAdapter(Context context) { | ||
| 88 | + this.context = context; | ||
| 89 | + mLayoutInflater = LayoutInflater.from(context); | ||
| 90 | + // 获取系统宽度 | ||
| 91 | + WindowManager wManager = (WindowManager) context | ||
| 92 | + .getSystemService(Context.WINDOW_SERVICE); | ||
| 93 | + DisplayMetrics outMetrics = new DisplayMetrics(); | ||
| 94 | + wManager.getDefaultDisplay().getMetrics(outMetrics); | ||
| 95 | + mMaxItemWith = (int) (outMetrics.widthPixels * 0.5f); | ||
| 96 | + mMinItemWith = (int) (outMetrics.widthPixels * 0.15f); | ||
| 97 | + handler = new MyHandler(this); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public static class MyHandler extends Handler { | ||
| 101 | + private final WeakReference<ChatListViewAdapter> mTbAdapter; | ||
| 102 | + | ||
| 103 | + public MyHandler(ChatListViewAdapter tbAdapter) { | ||
| 104 | + mTbAdapter = new WeakReference<ChatListViewAdapter>(tbAdapter); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + @Override | ||
| 108 | + public void handleMessage(Message msg) { | ||
| 109 | + ChatListViewAdapter tbAdapter = mTbAdapter.get(); | ||
| 110 | + | ||
| 111 | + if (tbAdapter != null) { | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + public void setIsGif(boolean isGif) { | ||
| 117 | + this.isGif = isGif; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public void setUserList(List<ChatMessageBean> userList) { | ||
| 121 | + this.userList = userList; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public void setImageList(ArrayList<String> imageList) { | ||
| 125 | + this.imageList = imageList; | ||
| 126 | + } | ||
| 127 | + public void setImagePosition(HashMap<Integer,Integer> imagePosition) { | ||
| 128 | + this.imagePosition = imagePosition; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + @Override | ||
| 132 | + public int getCount() { | ||
| 133 | + return userList.size(); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + @Override | ||
| 137 | + public Object getItem(int i) { | ||
| 138 | + return userList.get(i); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + @Override | ||
| 142 | + public long getItemId(int i) { | ||
| 143 | + return i; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + @Override | ||
| 147 | + public int getItemViewType(int position) { | ||
| 148 | + // TODO Auto-generated method stub | ||
| 149 | + return userList.get(position).getType(); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + @Override | ||
| 153 | + public int getViewTypeCount() { | ||
| 154 | + // TODO Auto-generated method stub | ||
| 155 | + return 6; | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + @SuppressLint("InflateParams") | ||
| 159 | + @Override | ||
| 160 | + public View getView(int i, View view, ViewGroup viewGroup) { | ||
| 161 | + ChatMessageBean tbub = userList.get(i); | ||
| 162 | + switch (getItemViewType(i)) { | ||
| 163 | + case FROM_USER_MSG: | ||
| 164 | + FromUserMsgViewHolder holder; | ||
| 165 | + if (view == null) { | ||
| 166 | + holder = new FromUserMsgViewHolder(); | ||
| 167 | + view = mLayoutInflater.inflate(R.layout.layout_msgfrom_list_item, null); | ||
| 168 | + holder.headicon = (ImageView) view | ||
| 169 | + .findViewById(R.id.tb_other_user_icon); | ||
| 170 | + holder.chat_time = (TextView) view.findViewById(R.id.chat_time); | ||
| 171 | + holder.content = (GifTextView) view.findViewById(R.id.content); | ||
| 172 | + view.setTag(holder); | ||
| 173 | + } else { | ||
| 174 | + holder = (FromUserMsgViewHolder) view.getTag(); | ||
| 175 | + } | ||
| 176 | + fromMsgUserLayout((FromUserMsgViewHolder) holder, tbub, i); | ||
| 177 | + break; | ||
| 178 | + case FROM_USER_IMG: | ||
| 179 | + FromUserImageViewHolder holder1; | ||
| 180 | + if (view == null) { | ||
| 181 | + holder1 = new FromUserImageViewHolder(); | ||
| 182 | + view = mLayoutInflater.inflate(R.layout.layout_imagefrom_list_item, null); | ||
| 183 | + holder1.headicon = (ImageView) view | ||
| 184 | + .findViewById(R.id.tb_other_user_icon); | ||
| 185 | + holder1.chat_time = (TextView) view.findViewById(R.id.chat_time); | ||
| 186 | + holder1.image_Msg = (BubbleImageView) view | ||
| 187 | + .findViewById(R.id.image_message); | ||
| 188 | + view.setTag(holder1); | ||
| 189 | + } else { | ||
| 190 | + holder1 = (FromUserImageViewHolder) view.getTag(); | ||
| 191 | + } | ||
| 192 | + fromImgUserLayout((FromUserImageViewHolder) holder1, tbub, i); | ||
| 193 | + break; | ||
| 194 | + case FROM_USER_VOICE: | ||
| 195 | + FromUserVoiceViewHolder holder2; | ||
| 196 | + if (view == null) { | ||
| 197 | + holder2 = new FromUserVoiceViewHolder(); | ||
| 198 | + view = mLayoutInflater.inflate(R.layout.layout_voicefrom_list_item, null); | ||
| 199 | + holder2.headicon = (ImageView) view | ||
| 200 | + .findViewById(R.id.tb_other_user_icon); | ||
| 201 | + holder2.chat_time = (TextView) view.findViewById(R.id.chat_time); | ||
| 202 | + holder2.voice_group = (LinearLayout) view | ||
| 203 | + .findViewById(R.id.voice_group); | ||
| 204 | + holder2.voice_time = (TextView) view | ||
| 205 | + .findViewById(R.id.voice_time); | ||
| 206 | + holder2.receiver_voice_unread = (View) view | ||
| 207 | + .findViewById(R.id.receiver_voice_unread); | ||
| 208 | + holder2.voice_image = (FrameLayout) view | ||
| 209 | + .findViewById(R.id.voice_receiver_image); | ||
| 210 | + holder2.voice_anim = (View) view | ||
| 211 | + .findViewById(R.id.id_receiver_recorder_anim); | ||
| 212 | + view.setTag(holder2); | ||
| 213 | + } else { | ||
| 214 | + holder2 = (FromUserVoiceViewHolder) view.getTag(); | ||
| 215 | + } | ||
| 216 | + fromVoiceUserLayout((FromUserVoiceViewHolder) holder2, tbub, i); | ||
| 217 | + break; | ||
| 218 | + case TO_USER_MSG: | ||
| 219 | + ToUserMsgViewHolder holder3; | ||
| 220 | + if (view == null) { | ||
| 221 | + holder3 = new ToUserMsgViewHolder(); | ||
| 222 | + view = mLayoutInflater.inflate(R.layout.layout_msgto_list_item, null); | ||
| 223 | + holder3.headicon = (ImageView) view | ||
| 224 | + .findViewById(R.id.tb_my_user_icon); | ||
| 225 | + holder3.chat_time = (TextView) view | ||
| 226 | + .findViewById(R.id.mychat_time); | ||
| 227 | + holder3.content = (GifTextView) view | ||
| 228 | + .findViewById(R.id.mycontent); | ||
| 229 | + holder3.sendFailImg = (ImageView) view | ||
| 230 | + .findViewById(R.id.mysend_fail_img); | ||
| 231 | + view.setTag(holder3); | ||
| 232 | + } else { | ||
| 233 | + holder3 = (ToUserMsgViewHolder) view.getTag(); | ||
| 234 | + } | ||
| 235 | + toMsgUserLayout((ToUserMsgViewHolder) holder3, tbub, i); | ||
| 236 | + break; | ||
| 237 | + case TO_USER_IMG: | ||
| 238 | + ToUserImgViewHolder holder4; | ||
| 239 | + if (view == null) { | ||
| 240 | + holder4 = new ToUserImgViewHolder(); | ||
| 241 | + view = mLayoutInflater.inflate(R.layout.layout_imageto_list_item, null); | ||
| 242 | + holder4.headicon = (ImageView) view | ||
| 243 | + .findViewById(R.id.tb_my_user_icon); | ||
| 244 | + holder4.chat_time = (TextView) view | ||
| 245 | + .findViewById(R.id.mychat_time); | ||
| 246 | + holder4.sendFailImg = (ImageView) view | ||
| 247 | + .findViewById(R.id.mysend_fail_img); | ||
| 248 | + holder4.image_group = (LinearLayout) view | ||
| 249 | + .findViewById(R.id.image_group); | ||
| 250 | + holder4.image_Msg = (BubbleImageView) view | ||
| 251 | + .findViewById(R.id.image_message); | ||
| 252 | + view.setTag(holder4); | ||
| 253 | + } else { | ||
| 254 | + holder4 = (ToUserImgViewHolder) view.getTag(); | ||
| 255 | + } | ||
| 256 | + toImgUserLayout((ToUserImgViewHolder) holder4, tbub, i); | ||
| 257 | + break; | ||
| 258 | + case TO_USER_VOICE: | ||
| 259 | + ToUserVoiceViewHolder holder5; | ||
| 260 | + if (view == null) { | ||
| 261 | + holder5 = new ToUserVoiceViewHolder(); | ||
| 262 | + view = mLayoutInflater.inflate(R.layout.layout_voiceto_list_item, null); | ||
| 263 | + holder5.headicon = (ImageView) view | ||
| 264 | + .findViewById(R.id.tb_my_user_icon); | ||
| 265 | + holder5.chat_time = (TextView) view | ||
| 266 | + .findViewById(R.id.mychat_time); | ||
| 267 | + holder5.voice_group = (LinearLayout) view | ||
| 268 | + .findViewById(R.id.voice_group); | ||
| 269 | + holder5.voice_time = (TextView) view | ||
| 270 | + .findViewById(R.id.voice_time); | ||
| 271 | + holder5.voice_image = (FrameLayout) view | ||
| 272 | + .findViewById(R.id.voice_image); | ||
| 273 | + holder5.voice_anim = (View) view | ||
| 274 | + .findViewById(R.id.id_recorder_anim); | ||
| 275 | + holder5.sendFailImg = (ImageView) view | ||
| 276 | + .findViewById(R.id.mysend_fail_img); | ||
| 277 | + view.setTag(holder5); | ||
| 278 | + } else { | ||
| 279 | + holder5 = (ToUserVoiceViewHolder) view.getTag(); | ||
| 280 | + } | ||
| 281 | + toVoiceUserLayout((ToUserVoiceViewHolder) holder5, tbub, i); | ||
| 282 | + break; | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | + return view; | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + public class FromUserMsgViewHolder { | ||
| 289 | + public ImageView headicon; | ||
| 290 | + public TextView chat_time; | ||
| 291 | + public GifTextView content; | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + public class FromUserImageViewHolder { | ||
| 295 | + public ImageView headicon; | ||
| 296 | + public TextView chat_time; | ||
| 297 | + public BubbleImageView image_Msg; | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + public class FromUserVoiceViewHolder { | ||
| 301 | + public ImageView headicon; | ||
| 302 | + public TextView chat_time; | ||
| 303 | + public LinearLayout voice_group; | ||
| 304 | + public TextView voice_time; | ||
| 305 | + public FrameLayout voice_image; | ||
| 306 | + public View receiver_voice_unread; | ||
| 307 | + public View voice_anim; | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + public class ToUserMsgViewHolder { | ||
| 311 | + public ImageView headicon; | ||
| 312 | + public TextView chat_time; | ||
| 313 | + public GifTextView content; | ||
| 314 | + public ImageView sendFailImg; | ||
| 315 | + } | ||
| 316 | + | ||
| 317 | + public class ToUserImgViewHolder { | ||
| 318 | + public ImageView headicon; | ||
| 319 | + public TextView chat_time; | ||
| 320 | + public LinearLayout image_group; | ||
| 321 | + public BubbleImageView image_Msg; | ||
| 322 | + public ImageView sendFailImg; | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + public class ToUserVoiceViewHolder { | ||
| 326 | + public ImageView headicon; | ||
| 327 | + public TextView chat_time; | ||
| 328 | + public LinearLayout voice_group; | ||
| 329 | + public TextView voice_time; | ||
| 330 | + public FrameLayout voice_image; | ||
| 331 | + public View receiver_voice_unread; | ||
| 332 | + public View voice_anim; | ||
| 333 | + public ImageView sendFailImg; | ||
| 334 | + } | ||
| 335 | + | ||
| 336 | + private void fromMsgUserLayout(final FromUserMsgViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 337 | + holder.headicon.setBackgroundResource(R.mipmap.tongbao_hiv); | ||
| 338 | + /* time */ | ||
| 339 | + if (position != 0) { | ||
| 340 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 341 | + .getTime()); | ||
| 342 | + if (showTime != null) { | ||
| 343 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 344 | + holder.chat_time.setText(showTime); | ||
| 345 | + } else { | ||
| 346 | + holder.chat_time.setVisibility(View.GONE); | ||
| 347 | + } | ||
| 348 | + } else { | ||
| 349 | + String showTime = getTime(tbub.getTime(), null); | ||
| 350 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 351 | + holder.chat_time.setText(showTime); | ||
| 352 | + } | ||
| 353 | + holder.content.setVisibility(View.VISIBLE); | ||
| 354 | + holder.content.setSpanText(handler, tbub.getUserContent(), isGif); | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + private void fromImgUserLayout(final FromUserImageViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 358 | + holder.headicon.setBackgroundResource(R.mipmap.tongbao_hiv); | ||
| 359 | + /* time */ | ||
| 360 | + if (position != 0) { | ||
| 361 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 362 | + .getTime()); | ||
| 363 | + if (showTime != null) { | ||
| 364 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 365 | + holder.chat_time.setText(showTime); | ||
| 366 | + } else { | ||
| 367 | + holder.chat_time.setVisibility(View.GONE); | ||
| 368 | + } | ||
| 369 | + } else { | ||
| 370 | + String showTime = getTime(tbub.getTime(), null); | ||
| 371 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 372 | + holder.chat_time.setText(showTime); | ||
| 373 | + } | ||
| 374 | + if (isPicRefresh) { | ||
| 375 | +// holder.image_Msg.setImageBitmap(null); | ||
| 376 | + final String imageSrc = tbub.getImageLocal() == null ? "" : tbub | ||
| 377 | + .getImageLocal(); | ||
| 378 | + final String imageUrlSrc = tbub.getImageUrl() == null ? "" : tbub | ||
| 379 | + .getImageUrl(); | ||
| 380 | + final String imageIconUrl = tbub.getImageIconUrl() == null ? "" | ||
| 381 | + : tbub.getImageIconUrl(); | ||
| 382 | + File file = new File(imageSrc); | ||
| 383 | + final boolean hasLocal = !imageSrc.equals("") | ||
| 384 | + && FileSaveUtil.isFileExists(file); | ||
| 385 | + int res; | ||
| 386 | + res = R.drawable.chatfrom_bg_focused; | ||
| 387 | + if (hasLocal) { | ||
| 388 | + holder.image_Msg.setLocalImageBitmap(ImageCheckoutUtil.getLoacalBitmap(imageSrc), | ||
| 389 | + res); | ||
| 390 | + } else { | ||
| 391 | + holder.image_Msg.load(imageIconUrl, res, R.mipmap.cygs_cs); | ||
| 392 | + } | ||
| 393 | + holder.image_Msg.setOnClickListener(new View.OnClickListener() { | ||
| 394 | + | ||
| 395 | + @Override | ||
| 396 | + public void onClick(View view) { | ||
| 397 | + // TODO Auto-generated method stub | ||
| 398 | + stopPlayVoice(); | ||
| 399 | + Intent intent = new Intent(context, ImageViewActivity.class); | ||
| 400 | + intent.putStringArrayListExtra("images", imageList); | ||
| 401 | + intent.putExtra("clickedIndex", imagePosition.get(position)); | ||
| 402 | + context.startActivity(intent); | ||
| 403 | + } | ||
| 404 | + | ||
| 405 | + }); | ||
| 406 | + } | ||
| 407 | + | ||
| 408 | + } | ||
| 409 | + | ||
| 410 | + private void fromVoiceUserLayout(final FromUserVoiceViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 411 | + holder.headicon.setBackgroundResource(R.mipmap.tongbao_hiv); | ||
| 412 | + /* time */ | ||
| 413 | + if (position != 0) { | ||
| 414 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 415 | + .getTime()); | ||
| 416 | + if (showTime != null) { | ||
| 417 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 418 | + holder.chat_time.setText(showTime); | ||
| 419 | + } else { | ||
| 420 | + holder.chat_time.setVisibility(View.GONE); | ||
| 421 | + } | ||
| 422 | + } else { | ||
| 423 | + String showTime = getTime(tbub.getTime(), null); | ||
| 424 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 425 | + holder.chat_time.setText(showTime); | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + holder.voice_group.setVisibility(View.VISIBLE); | ||
| 429 | + if (holder.receiver_voice_unread != null) | ||
| 430 | + holder.receiver_voice_unread.setVisibility(View.GONE); | ||
| 431 | + if (holder.receiver_voice_unread != null && unReadPosition != null) { | ||
| 432 | + for (String unRead : unReadPosition) { | ||
| 433 | + if (unRead.equals(position + "")) { | ||
| 434 | + holder.receiver_voice_unread | ||
| 435 | + .setVisibility(View.VISIBLE); | ||
| 436 | + break; | ||
| 437 | + } | ||
| 438 | + } | ||
| 439 | + } | ||
| 440 | + AnimationDrawable drawable; | ||
| 441 | + holder.voice_anim.setId(position); | ||
| 442 | + if (position == voicePlayPosition) { | ||
| 443 | + holder.voice_anim | ||
| 444 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 445 | + holder.voice_anim | ||
| 446 | + .setBackgroundResource(R.drawable.voice_play_receiver); | ||
| 447 | + drawable = (AnimationDrawable) holder.voice_anim | ||
| 448 | + .getBackground(); | ||
| 449 | + drawable.start(); | ||
| 450 | + } else { | ||
| 451 | + holder.voice_anim | ||
| 452 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 453 | + } | ||
| 454 | + holder.voice_group.setOnClickListener(new View.OnClickListener() { | ||
| 455 | + | ||
| 456 | + @Override | ||
| 457 | + public void onClick(View v) { | ||
| 458 | + // TODO Auto-generated method stub | ||
| 459 | + if (holder.receiver_voice_unread != null) | ||
| 460 | + holder.receiver_voice_unread.setVisibility(View.GONE); | ||
| 461 | + holder.voice_anim | ||
| 462 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 463 | + stopPlayVoice(); | ||
| 464 | + voicePlayPosition = holder.voice_anim.getId(); | ||
| 465 | + AnimationDrawable drawable; | ||
| 466 | + holder.voice_anim | ||
| 467 | + .setBackgroundResource(R.drawable.voice_play_receiver); | ||
| 468 | + drawable = (AnimationDrawable) holder.voice_anim | ||
| 469 | + .getBackground(); | ||
| 470 | + drawable.start(); | ||
| 471 | + String voicePath = tbub.getUserVoicePath() == null ? "" : tbub | ||
| 472 | + .getUserVoicePath(); | ||
| 473 | + File file = new File(voicePath); | ||
| 474 | + if (!(!voicePath.equals("") && FileSaveUtil | ||
| 475 | + .isFileExists(file))) { | ||
| 476 | + voicePath = tbub.getUserVoiceUrl() == null ? "" | ||
| 477 | + : tbub.getUserVoiceUrl(); | ||
| 478 | + } | ||
| 479 | + if (voiceIsRead != null) { | ||
| 480 | + voiceIsRead.voiceOnClick(position); | ||
| 481 | + } | ||
| 482 | + MediaManager.playSound(voicePath, | ||
| 483 | + new MediaPlayer.OnCompletionListener() { | ||
| 484 | + | ||
| 485 | + @Override | ||
| 486 | + public void onCompletion(MediaPlayer mp) { | ||
| 487 | + voicePlayPosition = -1; | ||
| 488 | + holder.voice_anim | ||
| 489 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 490 | + } | ||
| 491 | + }); | ||
| 492 | + } | ||
| 493 | + | ||
| 494 | + }); | ||
| 495 | + float voiceTime = tbub.getUserVoiceTime(); | ||
| 496 | + BigDecimal b = new BigDecimal(voiceTime); | ||
| 497 | + float f1 = b.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue(); | ||
| 498 | + holder.voice_time.setText(f1 + "\""); | ||
| 499 | + ViewGroup.LayoutParams lParams = holder.voice_image | ||
| 500 | + .getLayoutParams(); | ||
| 501 | + lParams.width = (int) (mMinItemWith + mMaxItemWith / 60f | ||
| 502 | + * tbub.getUserVoiceTime()); | ||
| 503 | + holder.voice_image.setLayoutParams(lParams); | ||
| 504 | + } | ||
| 505 | + | ||
| 506 | + private void toMsgUserLayout(final ToUserMsgViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 507 | + holder.headicon.setBackgroundResource(R.mipmap.grzx_tx_s); | ||
| 508 | + holder.headicon.setImageDrawable(context.getResources() | ||
| 509 | + .getDrawable(R.mipmap.grzx_tx_s)); | ||
| 510 | + /* time */ | ||
| 511 | + if (position != 0) { | ||
| 512 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 513 | + .getTime()); | ||
| 514 | + if (showTime != null) { | ||
| 515 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 516 | + holder.chat_time.setText(showTime); | ||
| 517 | + } else { | ||
| 518 | + holder.chat_time.setVisibility(View.GONE); | ||
| 519 | + } | ||
| 520 | + } else { | ||
| 521 | + String showTime = getTime(tbub.getTime(), null); | ||
| 522 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 523 | + holder.chat_time.setText(showTime); | ||
| 524 | + } | ||
| 525 | + | ||
| 526 | + holder.content.setVisibility(View.VISIBLE); | ||
| 527 | + holder.content.setSpanText(handler, tbub.getUserContent(), isGif); | ||
| 528 | + } | ||
| 529 | + | ||
| 530 | + private void toImgUserLayout(final ToUserImgViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 531 | + holder.headicon.setBackgroundResource(R.mipmap.grzx_tx_s); | ||
| 532 | + switch (tbub.getSendState()) { | ||
| 533 | + case ChatConst.SENDING: | ||
| 534 | + an = AnimationUtils.loadAnimation(context, | ||
| 535 | + R.anim.update_loading_progressbar_anim); | ||
| 536 | + LinearInterpolator lin = new LinearInterpolator(); | ||
| 537 | + an.setInterpolator(lin); | ||
| 538 | + an.setRepeatCount(-1); | ||
| 539 | + holder.sendFailImg | ||
| 540 | + .setBackgroundResource(R.mipmap.xsearch_loading); | ||
| 541 | + holder.sendFailImg.startAnimation(an); | ||
| 542 | + an.startNow(); | ||
| 543 | + holder.sendFailImg.setVisibility(View.VISIBLE); | ||
| 544 | + break; | ||
| 545 | + | ||
| 546 | + case ChatConst.COMPLETED: | ||
| 547 | + holder.sendFailImg.clearAnimation(); | ||
| 548 | + holder.sendFailImg.setVisibility(View.GONE); | ||
| 549 | + break; | ||
| 550 | + | ||
| 551 | + case ChatConst.SENDERROR: | ||
| 552 | + holder.sendFailImg.clearAnimation(); | ||
| 553 | + holder.sendFailImg | ||
| 554 | + .setBackgroundResource(R.mipmap.msg_state_fail_resend_pressed); | ||
| 555 | + holder.sendFailImg.setVisibility(View.VISIBLE); | ||
| 556 | + holder.sendFailImg.setOnClickListener(new View.OnClickListener() { | ||
| 557 | + | ||
| 558 | + @Override | ||
| 559 | + public void onClick(View view) { | ||
| 560 | + // TODO Auto-generated method stub | ||
| 561 | + if (sendErrorListener != null) { | ||
| 562 | + sendErrorListener.onClick(position); | ||
| 563 | + } | ||
| 564 | + } | ||
| 565 | + | ||
| 566 | + }); | ||
| 567 | + break; | ||
| 568 | + default: | ||
| 569 | + break; | ||
| 570 | + } | ||
| 571 | + holder.headicon.setImageDrawable(context.getResources() | ||
| 572 | + .getDrawable(R.mipmap.grzx_tx_s)); | ||
| 573 | + | ||
| 574 | + /* time */ | ||
| 575 | + if (position != 0) { | ||
| 576 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 577 | + .getTime()); | ||
| 578 | + if (showTime != null) { | ||
| 579 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 580 | + holder.chat_time.setText(showTime); | ||
| 581 | + } else { | ||
| 582 | + holder.chat_time.setVisibility(View.GONE); | ||
| 583 | + } | ||
| 584 | + } else { | ||
| 585 | + String showTime = getTime(tbub.getTime(), null); | ||
| 586 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 587 | + holder.chat_time.setText(showTime); | ||
| 588 | + } | ||
| 589 | + | ||
| 590 | + if (isPicRefresh) { | ||
| 591 | +// holder.image_Msg.setImageBitmap(null); | ||
| 592 | + holder.image_group.setVisibility(View.VISIBLE); | ||
| 593 | + final String imageSrc = tbub.getImageLocal() == null ? "" : tbub | ||
| 594 | + .getImageLocal(); | ||
| 595 | + final String imageUrlSrc = tbub.getImageUrl() == null ? "" : tbub | ||
| 596 | + .getImageUrl(); | ||
| 597 | + final String imageIconUrl = tbub.getImageIconUrl() == null ? "" | ||
| 598 | + : tbub.getImageIconUrl(); | ||
| 599 | + File file = new File(imageSrc); | ||
| 600 | + final boolean hasLocal = !imageSrc.equals("") | ||
| 601 | + && FileSaveUtil.isFileExists(file); | ||
| 602 | + int res; | ||
| 603 | + res = R.drawable.chatto_bg_focused; | ||
| 604 | + if (hasLocal) { | ||
| 605 | + holder.image_Msg.setLocalImageBitmap(ImageCheckoutUtil.getLoacalBitmap(imageSrc), | ||
| 606 | + res); | ||
| 607 | + } else { | ||
| 608 | + holder.image_Msg.load(imageIconUrl, res, R.mipmap.cygs_cs); | ||
| 609 | + } | ||
| 610 | + holder.image_Msg.setOnClickListener(new View.OnClickListener() { | ||
| 611 | + | ||
| 612 | + @Override | ||
| 613 | + public void onClick(View view) { | ||
| 614 | + // TODO Auto-generated method stub | ||
| 615 | + stopPlayVoice(); | ||
| 616 | + Intent intent = new Intent(context, ImageViewActivity.class); | ||
| 617 | + intent.putStringArrayListExtra("images", imageList); | ||
| 618 | + intent.putExtra("clickedIndex", imagePosition.get(position)); | ||
| 619 | + context.startActivity(intent); | ||
| 620 | + } | ||
| 621 | + | ||
| 622 | + }); | ||
| 623 | + } | ||
| 624 | + } | ||
| 625 | + | ||
| 626 | + private void toVoiceUserLayout(final ToUserVoiceViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 627 | + holder.headicon.setBackgroundResource(R.mipmap.grzx_tx_s); | ||
| 628 | + switch (tbub.getSendState()) { | ||
| 629 | + case ChatConst.SENDING: | ||
| 630 | + an = AnimationUtils.loadAnimation(context, | ||
| 631 | + R.anim.update_loading_progressbar_anim); | ||
| 632 | + LinearInterpolator lin = new LinearInterpolator(); | ||
| 633 | + an.setInterpolator(lin); | ||
| 634 | + an.setRepeatCount(-1); | ||
| 635 | + holder.sendFailImg | ||
| 636 | + .setBackgroundResource(R.mipmap.xsearch_loading); | ||
| 637 | + holder.sendFailImg.startAnimation(an); | ||
| 638 | + an.startNow(); | ||
| 639 | + holder.sendFailImg.setVisibility(View.VISIBLE); | ||
| 640 | + break; | ||
| 641 | + | ||
| 642 | + case ChatConst.COMPLETED: | ||
| 643 | + holder.sendFailImg.clearAnimation(); | ||
| 644 | + holder.sendFailImg.setVisibility(View.GONE); | ||
| 645 | + break; | ||
| 646 | + | ||
| 647 | + case ChatConst.SENDERROR: | ||
| 648 | + holder.sendFailImg.clearAnimation(); | ||
| 649 | + holder.sendFailImg | ||
| 650 | + .setBackgroundResource(R.mipmap.msg_state_fail_resend_pressed); | ||
| 651 | + holder.sendFailImg.setVisibility(View.VISIBLE); | ||
| 652 | + holder.sendFailImg.setOnClickListener(new View.OnClickListener() { | ||
| 653 | + | ||
| 654 | + @Override | ||
| 655 | + public void onClick(View view) { | ||
| 656 | + // TODO Auto-generated method stub | ||
| 657 | + if (sendErrorListener != null) { | ||
| 658 | + sendErrorListener.onClick(position); | ||
| 659 | + } | ||
| 660 | + } | ||
| 661 | + | ||
| 662 | + }); | ||
| 663 | + break; | ||
| 664 | + default: | ||
| 665 | + break; | ||
| 666 | + } | ||
| 667 | + holder.headicon.setImageDrawable(context.getResources() | ||
| 668 | + .getDrawable(R.mipmap.grzx_tx_s)); | ||
| 669 | + | ||
| 670 | + /* time */ | ||
| 671 | + if (position != 0) { | ||
| 672 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 673 | + .getTime()); | ||
| 674 | + if (showTime != null) { | ||
| 675 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 676 | + holder.chat_time.setText(showTime); | ||
| 677 | + } else { | ||
| 678 | + holder.chat_time.setVisibility(View.GONE); | ||
| 679 | + } | ||
| 680 | + } else { | ||
| 681 | + String showTime = getTime(tbub.getTime(), null); | ||
| 682 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 683 | + holder.chat_time.setText(showTime); | ||
| 684 | + } | ||
| 685 | + holder.voice_group.setVisibility(View.VISIBLE); | ||
| 686 | + if (holder.receiver_voice_unread != null) | ||
| 687 | + holder.receiver_voice_unread.setVisibility(View.GONE); | ||
| 688 | + if (holder.receiver_voice_unread != null && unReadPosition != null) { | ||
| 689 | + for (String unRead : unReadPosition) { | ||
| 690 | + if (unRead.equals(position + "")) { | ||
| 691 | + holder.receiver_voice_unread | ||
| 692 | + .setVisibility(View.VISIBLE); | ||
| 693 | + break; | ||
| 694 | + } | ||
| 695 | + } | ||
| 696 | + } | ||
| 697 | + AnimationDrawable drawable; | ||
| 698 | + holder.voice_anim.setId(position); | ||
| 699 | + if (position == voicePlayPosition) { | ||
| 700 | + holder.voice_anim.setBackgroundResource(R.mipmap.adj); | ||
| 701 | + holder.voice_anim | ||
| 702 | + .setBackgroundResource(R.drawable.voice_play_send); | ||
| 703 | + drawable = (AnimationDrawable) holder.voice_anim | ||
| 704 | + .getBackground(); | ||
| 705 | + drawable.start(); | ||
| 706 | + } else { | ||
| 707 | + holder.voice_anim.setBackgroundResource(R.mipmap.adj); | ||
| 708 | + } | ||
| 709 | + holder.voice_group.setOnClickListener(new View.OnClickListener() { | ||
| 710 | + | ||
| 711 | + @Override | ||
| 712 | + public void onClick(View v) { | ||
| 713 | + // TODO Auto-generated method stub | ||
| 714 | + if (holder.receiver_voice_unread != null) | ||
| 715 | + holder.receiver_voice_unread.setVisibility(View.GONE); | ||
| 716 | + holder.voice_anim.setBackgroundResource(R.mipmap.adj); | ||
| 717 | + stopPlayVoice(); | ||
| 718 | + voicePlayPosition = holder.voice_anim.getId(); | ||
| 719 | + AnimationDrawable drawable; | ||
| 720 | + holder.voice_anim | ||
| 721 | + .setBackgroundResource(R.drawable.voice_play_send); | ||
| 722 | + drawable = (AnimationDrawable) holder.voice_anim | ||
| 723 | + .getBackground(); | ||
| 724 | + drawable.start(); | ||
| 725 | + String voicePath = tbub.getUserVoiceUrl() == null ? "" | ||
| 726 | + : tbub.getUserVoiceUrl(); | ||
| 727 | + if (voiceIsRead != null) { | ||
| 728 | + voiceIsRead.voiceOnClick(position); | ||
| 729 | + } | ||
| 730 | + MediaManager.playSound(voicePath, | ||
| 731 | + new MediaPlayer.OnCompletionListener() { | ||
| 732 | + | ||
| 733 | + @Override | ||
| 734 | + public void onCompletion(MediaPlayer mp) { | ||
| 735 | + voicePlayPosition = -1; | ||
| 736 | + holder.voice_anim | ||
| 737 | + .setBackgroundResource(R.mipmap.adj); | ||
| 738 | + } | ||
| 739 | + }); | ||
| 740 | + } | ||
| 741 | + | ||
| 742 | + }); | ||
| 743 | + float voiceTime = tbub.getUserVoiceTime(); | ||
| 744 | + BigDecimal b = new BigDecimal(voiceTime); | ||
| 745 | + float f1 = b.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue(); | ||
| 746 | + holder.voice_time.setText(f1 + "\""); | ||
| 747 | + ViewGroup.LayoutParams lParams = holder.voice_image | ||
| 748 | + .getLayoutParams(); | ||
| 749 | + lParams.width = (int) (mMinItemWith + mMaxItemWith / 60f | ||
| 750 | + * tbub.getUserVoiceTime()); | ||
| 751 | + holder.voice_image.setLayoutParams(lParams); | ||
| 752 | + } | ||
| 753 | + | ||
| 754 | + @SuppressLint("SimpleDateFormat") | ||
| 755 | + public String getTime(String time, String before) { | ||
| 756 | + String show_time = null; | ||
| 757 | + if (before != null) { | ||
| 758 | + try { | ||
| 759 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 760 | + java.util.Date now = df.parse(time); | ||
| 761 | + java.util.Date date = df.parse(before); | ||
| 762 | + long l = now.getTime() - date.getTime(); | ||
| 763 | + long day = l / (24 * 60 * 60 * 1000); | ||
| 764 | + long hour = (l / (60 * 60 * 1000) - day * 24); | ||
| 765 | + long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60); | ||
| 766 | + if (min >= 1) { | ||
| 767 | + show_time = time.substring(11); | ||
| 768 | + } | ||
| 769 | + } catch (Exception e) { | ||
| 770 | + e.printStackTrace(); | ||
| 771 | + } | ||
| 772 | + } else { | ||
| 773 | + show_time = time.substring(11); | ||
| 774 | + } | ||
| 775 | + String getDay = getDay(time); | ||
| 776 | + if (show_time != null && getDay != null) | ||
| 777 | + show_time = getDay + " " + show_time; | ||
| 778 | + return show_time; | ||
| 779 | + } | ||
| 780 | + | ||
| 781 | + @SuppressLint("SimpleDateFormat") | ||
| 782 | + public static String returnTime() { | ||
| 783 | + SimpleDateFormat sDateFormat = new SimpleDateFormat( | ||
| 784 | + "yyyy-MM-dd HH:mm:ss"); | ||
| 785 | + String date = sDateFormat.format(new java.util.Date()); | ||
| 786 | + return date; | ||
| 787 | + } | ||
| 788 | + | ||
| 789 | + @SuppressLint("SimpleDateFormat") | ||
| 790 | + public String getDay(String time) { | ||
| 791 | + String showDay = null; | ||
| 792 | + String nowTime = returnTime(); | ||
| 793 | + try { | ||
| 794 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 795 | + java.util.Date now = df.parse(nowTime); | ||
| 796 | + java.util.Date date = df.parse(time); | ||
| 797 | + long l = now.getTime() - date.getTime(); | ||
| 798 | + long day = l / (24 * 60 * 60 * 1000); | ||
| 799 | + if (day >= 365) { | ||
| 800 | + showDay = time.substring(0, 10); | ||
| 801 | + } else if (day >= 1 && day < 365) { | ||
| 802 | + showDay = time.substring(5, 10); | ||
| 803 | + } | ||
| 804 | + } catch (Exception e) { | ||
| 805 | + e.printStackTrace(); | ||
| 806 | + } | ||
| 807 | + return showDay; | ||
| 808 | + } | ||
| 809 | + | ||
| 810 | + public void stopPlayVoice() { | ||
| 811 | + if (voicePlayPosition != -1) { | ||
| 812 | + View voicePlay = (View) ((Activity) context) | ||
| 813 | + .findViewById(voicePlayPosition); | ||
| 814 | + if (voicePlay != null) { | ||
| 815 | + if (getItemViewType(voicePlayPosition) == FROM_USER_VOICE) { | ||
| 816 | + voicePlay | ||
| 817 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 818 | + } else { | ||
| 819 | + voicePlay.setBackgroundResource(R.mipmap.adj); | ||
| 820 | + } | ||
| 821 | + } | ||
| 822 | + MediaManager.pause(); | ||
| 823 | + voicePlayPosition = -1; | ||
| 824 | + } | ||
| 825 | + } | ||
| 826 | +} |
app/src/main/java/com/shunzhi/parent/ui/activity/chartroom/adapter/ChatRecyclerAdapter.java
0 → 100644
| @@ -0,0 +1,858 @@ | @@ -0,0 +1,858 @@ | ||
| 1 | +package com.shunzhi.parent.ui.activity.chartroom.adapter; | ||
| 2 | + | ||
| 3 | +import android.annotation.SuppressLint; | ||
| 4 | +import android.app.Activity; | ||
| 5 | +import android.content.Context; | ||
| 6 | +import android.content.Intent; | ||
| 7 | +import android.graphics.Bitmap; | ||
| 8 | +import android.graphics.BitmapFactory; | ||
| 9 | +import android.graphics.drawable.AnimationDrawable; | ||
| 10 | +import android.media.MediaPlayer; | ||
| 11 | +import android.os.Handler; | ||
| 12 | +import android.support.v7.widget.RecyclerView; | ||
| 13 | +import android.text.TextUtils; | ||
| 14 | +import android.util.DisplayMetrics; | ||
| 15 | +import android.view.LayoutInflater; | ||
| 16 | +import android.view.View; | ||
| 17 | +import android.view.ViewGroup; | ||
| 18 | +import android.view.WindowManager; | ||
| 19 | +import android.view.animation.Animation; | ||
| 20 | +import android.view.animation.AnimationUtils; | ||
| 21 | +import android.view.animation.LinearInterpolator; | ||
| 22 | +import android.widget.FrameLayout; | ||
| 23 | +import android.widget.ImageView; | ||
| 24 | +import android.widget.LinearLayout; | ||
| 25 | +import android.widget.TextView; | ||
| 26 | + | ||
| 27 | +import com.bumptech.glide.Glide; | ||
| 28 | +import com.shunzhi.mychartlibrary.db.ChatMessageBean; | ||
| 29 | +import com.shunzhi.parent.AppConfig; | ||
| 30 | +import com.shunzhi.parent.AppContext; | ||
| 31 | +import com.shunzhi.parent.R; | ||
| 32 | +import com.shunzhi.parent.ui.activity.chartroom.ImageViewActivity; | ||
| 33 | +import com.shunzhi.mychartlibrary.common.ChatConst; | ||
| 34 | +import com.shunzhi.mychartlibrary.utils.FileSaveUtil; | ||
| 35 | +import com.shunzhi.mychartlibrary.widget.BubbleImageView; | ||
| 36 | +import com.shunzhi.mychartlibrary.widget.CustomShapeTransformation; | ||
| 37 | +import com.shunzhi.mychartlibrary.widget.GifTextView; | ||
| 38 | +import com.shunzhi.mychartlibrary.widget.MediaManager; | ||
| 39 | +import com.shunzhi.parent.util.GlideUtils; | ||
| 40 | + | ||
| 41 | +import java.io.BufferedInputStream; | ||
| 42 | +import java.io.ByteArrayOutputStream; | ||
| 43 | +import java.io.File; | ||
| 44 | +import java.io.FileInputStream; | ||
| 45 | +import java.io.FileNotFoundException; | ||
| 46 | +import java.io.IOException; | ||
| 47 | +import java.math.BigDecimal; | ||
| 48 | +import java.text.DateFormat; | ||
| 49 | +import java.text.SimpleDateFormat; | ||
| 50 | +import java.util.ArrayList; | ||
| 51 | +import java.util.HashMap; | ||
| 52 | +import java.util.List; | ||
| 53 | + | ||
| 54 | +/** | ||
| 55 | + * Created by Mao Jiqing on 2016/9/29. | ||
| 56 | + */ | ||
| 57 | +public class ChatRecyclerAdapter extends | ||
| 58 | + RecyclerView.Adapter<RecyclerView.ViewHolder> { | ||
| 59 | + private Context context; | ||
| 60 | + private List<ChatMessageBean> userList = new ArrayList<ChatMessageBean>(); | ||
| 61 | + private ArrayList<String> imageList = new ArrayList<String>(); | ||
| 62 | + private HashMap<Integer, Integer> imagePosition = new HashMap<Integer, Integer>(); | ||
| 63 | + public static final int FROM_USER_MSG = 0;//接收消息类型 | ||
| 64 | + public static final int TO_USER_MSG = 1;//发送消息类型 | ||
| 65 | + public static final int FROM_USER_IMG = 2;//接收消息类型 | ||
| 66 | + public static final int TO_USER_IMG = 3;//发送消息类型 | ||
| 67 | + public static final int FROM_USER_VOICE = 4;//接收消息类型 | ||
| 68 | + public static final int TO_USER_VOICE = 5;//发送消息类型 | ||
| 69 | + private int mMinItemWith;// 设置对话框的最大宽度和最小宽度 | ||
| 70 | + private int mMaxItemWith; | ||
| 71 | + public Handler handler; | ||
| 72 | + private Animation an; | ||
| 73 | + private SendErrorListener sendErrorListener; | ||
| 74 | + private VoiceIsRead voiceIsRead; | ||
| 75 | + public List<String> unReadPosition = new ArrayList<String>(); | ||
| 76 | + private int voicePlayPosition = -1; | ||
| 77 | + private LayoutInflater mLayoutInflater; | ||
| 78 | + private boolean isGif = true; | ||
| 79 | + public boolean isPicRefresh = true; | ||
| 80 | + private String parentUrl = "",childPhoto; | ||
| 81 | + | ||
| 82 | + public interface SendErrorListener { | ||
| 83 | + public void onClick(int position); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public void setSendErrorListener(SendErrorListener sendErrorListener) { | ||
| 87 | + this.sendErrorListener = sendErrorListener; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + public interface VoiceIsRead { | ||
| 91 | + public void voiceOnClick(int position); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public void setVoiceIsReadListener(VoiceIsRead voiceIsRead) { | ||
| 95 | + this.voiceIsRead = voiceIsRead; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public ChatRecyclerAdapter(Context context, List<ChatMessageBean> userList,String childPhoto) { | ||
| 99 | + this.context = context; | ||
| 100 | + this.userList = userList; | ||
| 101 | + mLayoutInflater = LayoutInflater.from(context); | ||
| 102 | + // 获取系统宽度 | ||
| 103 | + WindowManager wManager = (WindowManager) context | ||
| 104 | + .getSystemService(Context.WINDOW_SERVICE); | ||
| 105 | + DisplayMetrics outMetrics = new DisplayMetrics(); | ||
| 106 | + wManager.getDefaultDisplay().getMetrics(outMetrics); | ||
| 107 | + mMaxItemWith = (int) (outMetrics.widthPixels * 0.5f); | ||
| 108 | + mMinItemWith = (int) (outMetrics.widthPixels * 0.15f); | ||
| 109 | + handler = new Handler(); | ||
| 110 | + parentUrl= AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.USER_IMAGE); | ||
| 111 | + this.childPhoto=childPhoto; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + public void setIsGif(boolean isGif) { | ||
| 115 | + this.isGif = isGif; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + public void setImageList(ArrayList<String> imageList) { | ||
| 119 | + this.imageList = imageList; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + public void setImagePosition(HashMap<Integer, Integer> imagePosition) { | ||
| 123 | + this.imagePosition = imagePosition; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + /** | ||
| 127 | + * @param parent | ||
| 128 | + * @param viewType | ||
| 129 | + * @return | ||
| 130 | + */ | ||
| 131 | + @Override | ||
| 132 | + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
| 133 | + View view = null; | ||
| 134 | + RecyclerView.ViewHolder holder = null; | ||
| 135 | + switch (viewType) { | ||
| 136 | + case FROM_USER_MSG: | ||
| 137 | + view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_msgfrom_list_item, parent, false); | ||
| 138 | + holder = new FromUserMsgViewHolder(view); | ||
| 139 | + break; | ||
| 140 | + case FROM_USER_IMG: | ||
| 141 | + view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_imagefrom_list_item, parent, false); | ||
| 142 | + holder = new FromUserImageViewHolder(view); | ||
| 143 | + break; | ||
| 144 | + case FROM_USER_VOICE: | ||
| 145 | + view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_voicefrom_list_item, parent, false); | ||
| 146 | + holder = new FromUserVoiceViewHolder(view); | ||
| 147 | + break; | ||
| 148 | + case TO_USER_MSG: | ||
| 149 | + view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_msgto_list_item, parent, false); | ||
| 150 | + holder = new ToUserMsgViewHolder(view); | ||
| 151 | + break; | ||
| 152 | + case TO_USER_IMG: | ||
| 153 | + view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_imageto_list_item, parent, false); | ||
| 154 | + holder = new ToUserImgViewHolder(view); | ||
| 155 | + break; | ||
| 156 | + case TO_USER_VOICE: | ||
| 157 | + view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_voiceto_list_item, parent, false); | ||
| 158 | + holder = new ToUserVoiceViewHolder(view); | ||
| 159 | + break; | ||
| 160 | + } | ||
| 161 | + return holder; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + class FromUserMsgViewHolder extends RecyclerView.ViewHolder { | ||
| 165 | + private ImageView headicon; | ||
| 166 | + private TextView chat_time; | ||
| 167 | + private GifTextView content; | ||
| 168 | + | ||
| 169 | + public FromUserMsgViewHolder(View view) { | ||
| 170 | + super(view); | ||
| 171 | + headicon = (ImageView) view | ||
| 172 | + .findViewById(R.id.tb_other_user_icon); | ||
| 173 | + chat_time = (TextView) view.findViewById(R.id.chat_time); | ||
| 174 | + content = (GifTextView) view.findViewById(R.id.content); | ||
| 175 | + } | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + class FromUserImageViewHolder extends RecyclerView.ViewHolder { | ||
| 179 | + private ImageView headicon; | ||
| 180 | + private TextView chat_time; | ||
| 181 | + private BubbleImageView image_Msg; | ||
| 182 | + | ||
| 183 | + public FromUserImageViewHolder(View view) { | ||
| 184 | + super(view); | ||
| 185 | + headicon = (ImageView) view | ||
| 186 | + .findViewById(R.id.tb_other_user_icon); | ||
| 187 | + chat_time = (TextView) view.findViewById(R.id.chat_time); | ||
| 188 | + image_Msg = (BubbleImageView) view | ||
| 189 | + .findViewById(R.id.image_message); | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + class FromUserVoiceViewHolder extends RecyclerView.ViewHolder { | ||
| 194 | + private ImageView headicon; | ||
| 195 | + private TextView chat_time; | ||
| 196 | + private LinearLayout voice_group; | ||
| 197 | + private TextView voice_time; | ||
| 198 | + private FrameLayout voice_image; | ||
| 199 | + private View receiver_voice_unread; | ||
| 200 | + private View voice_anim; | ||
| 201 | + | ||
| 202 | + public FromUserVoiceViewHolder(View view) { | ||
| 203 | + super(view); | ||
| 204 | + headicon = (ImageView) view | ||
| 205 | + .findViewById(R.id.tb_other_user_icon); | ||
| 206 | + chat_time = (TextView) view.findViewById(R.id.chat_time); | ||
| 207 | + voice_group = (LinearLayout) view | ||
| 208 | + .findViewById(R.id.voice_group); | ||
| 209 | + voice_time = (TextView) view | ||
| 210 | + .findViewById(R.id.voice_time); | ||
| 211 | + receiver_voice_unread = (View) view | ||
| 212 | + .findViewById(R.id.receiver_voice_unread); | ||
| 213 | + voice_image = (FrameLayout) view | ||
| 214 | + .findViewById(R.id.voice_receiver_image); | ||
| 215 | + voice_anim = (View) view | ||
| 216 | + .findViewById(R.id.id_receiver_recorder_anim); | ||
| 217 | + } | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + class ToUserMsgViewHolder extends RecyclerView.ViewHolder { | ||
| 221 | + private ImageView headicon; | ||
| 222 | + private TextView chat_time; | ||
| 223 | + private GifTextView content; | ||
| 224 | + private ImageView sendFailImg; | ||
| 225 | + | ||
| 226 | + public ToUserMsgViewHolder(View view) { | ||
| 227 | + super(view); | ||
| 228 | + headicon = (ImageView) view | ||
| 229 | + .findViewById(R.id.tb_my_user_icon); | ||
| 230 | + chat_time = (TextView) view | ||
| 231 | + .findViewById(R.id.mychat_time); | ||
| 232 | + content = (GifTextView) view | ||
| 233 | + .findViewById(R.id.mycontent); | ||
| 234 | + sendFailImg = (ImageView) view | ||
| 235 | + .findViewById(R.id.mysend_fail_img); | ||
| 236 | + } | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + class ToUserImgViewHolder extends RecyclerView.ViewHolder { | ||
| 240 | + private ImageView headicon; | ||
| 241 | + private TextView chat_time; | ||
| 242 | + private LinearLayout image_group; | ||
| 243 | + private BubbleImageView image_Msg; | ||
| 244 | + private ImageView sendFailImg; | ||
| 245 | + | ||
| 246 | + public ToUserImgViewHolder(View view) { | ||
| 247 | + super(view); | ||
| 248 | + headicon = (ImageView) view | ||
| 249 | + .findViewById(R.id.tb_my_user_icon); | ||
| 250 | + chat_time = (TextView) view | ||
| 251 | + .findViewById(R.id.mychat_time); | ||
| 252 | + sendFailImg = (ImageView) view | ||
| 253 | + .findViewById(R.id.mysend_fail_img); | ||
| 254 | + image_group = (LinearLayout) view | ||
| 255 | + .findViewById(R.id.image_group); | ||
| 256 | + image_Msg = (BubbleImageView) view | ||
| 257 | + .findViewById(R.id.image_message); | ||
| 258 | + } | ||
| 259 | + } | ||
| 260 | + | ||
| 261 | + class ToUserVoiceViewHolder extends RecyclerView.ViewHolder { | ||
| 262 | + private ImageView headicon; | ||
| 263 | + private TextView chat_time; | ||
| 264 | + private LinearLayout voice_group; | ||
| 265 | + private TextView voice_time; | ||
| 266 | + private FrameLayout voice_image; | ||
| 267 | + private View receiver_voice_unread; | ||
| 268 | + private View voice_anim; | ||
| 269 | + private ImageView sendFailImg; | ||
| 270 | + | ||
| 271 | + public ToUserVoiceViewHolder(View view) { | ||
| 272 | + super(view); | ||
| 273 | + headicon = (ImageView) view | ||
| 274 | + .findViewById(R.id.tb_my_user_icon); | ||
| 275 | + chat_time = (TextView) view | ||
| 276 | + .findViewById(R.id.mychat_time); | ||
| 277 | + voice_group = (LinearLayout) view | ||
| 278 | + .findViewById(R.id.voice_group); | ||
| 279 | + voice_time = (TextView) view | ||
| 280 | + .findViewById(R.id.voice_time); | ||
| 281 | + voice_image = (FrameLayout) view | ||
| 282 | + .findViewById(R.id.voice_image); | ||
| 283 | + voice_anim = (View) view | ||
| 284 | + .findViewById(R.id.id_recorder_anim); | ||
| 285 | + sendFailImg = (ImageView) view | ||
| 286 | + .findViewById(R.id.mysend_fail_img); | ||
| 287 | + } | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + /** | ||
| 291 | + * @param holder | ||
| 292 | + * @param position | ||
| 293 | + */ | ||
| 294 | + @Override | ||
| 295 | + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | ||
| 296 | + ChatMessageBean tbub = userList.get(position); | ||
| 297 | + int itemViewType = getItemViewType(position); | ||
| 298 | + switch (itemViewType) { | ||
| 299 | + case FROM_USER_MSG: | ||
| 300 | + fromMsgUserLayout((FromUserMsgViewHolder) holder, tbub, position); | ||
| 301 | + break; | ||
| 302 | + case FROM_USER_IMG: | ||
| 303 | + fromImgUserLayout((FromUserImageViewHolder) holder, tbub, position); | ||
| 304 | + break; | ||
| 305 | + case FROM_USER_VOICE: | ||
| 306 | + fromVoiceUserLayout((FromUserVoiceViewHolder) holder, tbub, position); | ||
| 307 | + break; | ||
| 308 | + case TO_USER_MSG: | ||
| 309 | + toMsgUserLayout((ToUserMsgViewHolder) holder, tbub, position); | ||
| 310 | + break; | ||
| 311 | + case TO_USER_IMG: | ||
| 312 | + toImgUserLayout((ToUserImgViewHolder) holder, tbub, position); | ||
| 313 | + break; | ||
| 314 | + case TO_USER_VOICE: | ||
| 315 | + toVoiceUserLayout((ToUserVoiceViewHolder) holder, tbub, position); | ||
| 316 | + break; | ||
| 317 | + } | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + @Override | ||
| 321 | + public int getItemViewType(int position) { | ||
| 322 | + return userList.get(position).getType(); | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + @Override | ||
| 326 | + public int getItemCount() { | ||
| 327 | + return userList.size(); | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + private void fromMsgUserLayout(final FromUserMsgViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 331 | +// holder.headicon.setBackgroundResource(R.mipmap.tongbao_hiv); | ||
| 332 | + if (!TextUtils.isEmpty(childPhoto)) | ||
| 333 | + GlideUtils.showImg(context,holder.headicon,childPhoto); | ||
| 334 | + else holder.headicon.setImageResource(R.drawable.header_icon); | ||
| 335 | + /* time */ | ||
| 336 | + if (position != 0) { | ||
| 337 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 338 | + .getTime()); | ||
| 339 | + if (showTime != null) { | ||
| 340 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 341 | + holder.chat_time.setText(showTime); | ||
| 342 | + } else { | ||
| 343 | + holder.chat_time.setVisibility(View.GONE); | ||
| 344 | + } | ||
| 345 | + } else { | ||
| 346 | + String showTime = getTime(tbub.getTime(), null); | ||
| 347 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 348 | + holder.chat_time.setText(showTime); | ||
| 349 | + } | ||
| 350 | + holder.content.setVisibility(View.VISIBLE); | ||
| 351 | + holder.content.setSpanText(handler, tbub.getUserContent(), isGif); | ||
| 352 | + } | ||
| 353 | + | ||
| 354 | + private void fromImgUserLayout(final FromUserImageViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 355 | + if (!TextUtils.isEmpty(childPhoto)) | ||
| 356 | + GlideUtils.showImg(context,holder.headicon,childPhoto); | ||
| 357 | + else holder.headicon.setImageResource(R.drawable.header_icon); | ||
| 358 | + /* time */ | ||
| 359 | + if (position != 0) { | ||
| 360 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 361 | + .getTime()); | ||
| 362 | + if (showTime != null) { | ||
| 363 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 364 | + holder.chat_time.setText(showTime); | ||
| 365 | + } else { | ||
| 366 | + holder.chat_time.setVisibility(View.GONE); | ||
| 367 | + } | ||
| 368 | + } else { | ||
| 369 | + String showTime = getTime(tbub.getTime(), null); | ||
| 370 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 371 | + holder.chat_time.setText(showTime); | ||
| 372 | + } | ||
| 373 | +// if (isPicRefresh) { | ||
| 374 | + final String imageSrc = tbub.getImageLocal() == null ? "" : tbub | ||
| 375 | + .getImageLocal(); | ||
| 376 | + final String imageUrlSrc = tbub.getImageUrl() == null ? "" : tbub | ||
| 377 | + .getImageUrl(); | ||
| 378 | + final String imageIconUrl = tbub.getImageIconUrl() == null ? "" | ||
| 379 | + : tbub.getImageIconUrl(); | ||
| 380 | + File file = new File(imageSrc); | ||
| 381 | + final boolean hasLocal = !imageSrc.equals("") | ||
| 382 | + && FileSaveUtil.isFileExists(file); | ||
| 383 | + int res; | ||
| 384 | + res = R.drawable.chatfrom_bg_focused; | ||
| 385 | +// Glide.with(context).load(imageSrc).transform(new CustomShapeTransformation(context, res)).into(holder.image_Msg); | ||
| 386 | + Glide.with(context).load(imageSrc).placeholder(R.mipmap.cygs_cs).transform(new CustomShapeTransformation(context, res)).into(holder.image_Msg); | ||
| 387 | + | ||
| 388 | + holder.image_Msg.setOnClickListener(new View.OnClickListener() { | ||
| 389 | + | ||
| 390 | + @Override | ||
| 391 | + public void onClick(View view) { | ||
| 392 | + // TODO Auto-generated method stub | ||
| 393 | + stopPlayVoice(); | ||
| 394 | + Intent intent = new Intent(context, ImageViewActivity.class); | ||
| 395 | + intent.putStringArrayListExtra("images", imageList); | ||
| 396 | + intent.putExtra("clickedIndex", imagePosition.get(position)); | ||
| 397 | + context.startActivity(intent); | ||
| 398 | + } | ||
| 399 | + | ||
| 400 | + }); | ||
| 401 | +// } | ||
| 402 | + | ||
| 403 | + } | ||
| 404 | + | ||
| 405 | + private void fromVoiceUserLayout(final FromUserVoiceViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 406 | + if (!TextUtils.isEmpty(childPhoto)) | ||
| 407 | + GlideUtils.showImg(context,holder.headicon,childPhoto); | ||
| 408 | + else holder.headicon.setImageResource(R.drawable.header_icon); | ||
| 409 | + /* time */ | ||
| 410 | + if (position != 0) { | ||
| 411 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 412 | + .getTime()); | ||
| 413 | + if (showTime != null) { | ||
| 414 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 415 | + holder.chat_time.setText(showTime); | ||
| 416 | + } else { | ||
| 417 | + holder.chat_time.setVisibility(View.GONE); | ||
| 418 | + } | ||
| 419 | + } else { | ||
| 420 | + String showTime = getTime(tbub.getTime(), null); | ||
| 421 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 422 | + holder.chat_time.setText(showTime); | ||
| 423 | + } | ||
| 424 | + | ||
| 425 | + holder.voice_group.setVisibility(View.VISIBLE); | ||
| 426 | + if (holder.receiver_voice_unread != null) | ||
| 427 | + holder.receiver_voice_unread.setVisibility(View.GONE); | ||
| 428 | + if (holder.receiver_voice_unread != null && unReadPosition != null) { | ||
| 429 | + for (String unRead : unReadPosition) { | ||
| 430 | + if (unRead.equals(position + "")) { | ||
| 431 | + holder.receiver_voice_unread | ||
| 432 | + .setVisibility(View.VISIBLE); | ||
| 433 | + break; | ||
| 434 | + } | ||
| 435 | + } | ||
| 436 | + } | ||
| 437 | + AnimationDrawable drawable; | ||
| 438 | + holder.voice_anim.setId(position); | ||
| 439 | + if (position == voicePlayPosition) { | ||
| 440 | + holder.voice_anim | ||
| 441 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 442 | + holder.voice_anim | ||
| 443 | + .setBackgroundResource(R.drawable.voice_play_receiver); | ||
| 444 | + drawable = (AnimationDrawable) holder.voice_anim | ||
| 445 | + .getBackground(); | ||
| 446 | + drawable.start(); | ||
| 447 | + } else { | ||
| 448 | + holder.voice_anim | ||
| 449 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 450 | + } | ||
| 451 | + holder.voice_group.setOnClickListener(new View.OnClickListener() { | ||
| 452 | + | ||
| 453 | + @Override | ||
| 454 | + public void onClick(View v) { | ||
| 455 | + // TODO Auto-generated method stub | ||
| 456 | + if (holder.receiver_voice_unread != null) | ||
| 457 | + holder.receiver_voice_unread.setVisibility(View.GONE); | ||
| 458 | + holder.voice_anim | ||
| 459 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 460 | + stopPlayVoice(); | ||
| 461 | + voicePlayPosition = holder.voice_anim.getId(); | ||
| 462 | + AnimationDrawable drawable; | ||
| 463 | + holder.voice_anim | ||
| 464 | + .setBackgroundResource(R.drawable.voice_play_receiver); | ||
| 465 | + drawable = (AnimationDrawable) holder.voice_anim | ||
| 466 | + .getBackground(); | ||
| 467 | + drawable.start(); | ||
| 468 | + String voicePath = tbub.getUserVoicePath() == null ? "" : tbub | ||
| 469 | + .getUserVoicePath(); | ||
| 470 | + File file = new File(voicePath); | ||
| 471 | + if (!(!voicePath.equals("") && FileSaveUtil | ||
| 472 | + .isFileExists(file))) { | ||
| 473 | + voicePath = tbub.getUserVoiceUrl() == null ? "" | ||
| 474 | + : tbub.getUserVoiceUrl(); | ||
| 475 | + } | ||
| 476 | + if (voiceIsRead != null) { | ||
| 477 | + voiceIsRead.voiceOnClick(position); | ||
| 478 | + } | ||
| 479 | + MediaManager.playSound(voicePath, | ||
| 480 | + new MediaPlayer.OnCompletionListener() { | ||
| 481 | + | ||
| 482 | + @Override | ||
| 483 | + public void onCompletion(MediaPlayer mp) { | ||
| 484 | + voicePlayPosition = -1; | ||
| 485 | + holder.voice_anim | ||
| 486 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 487 | + } | ||
| 488 | + }); | ||
| 489 | + } | ||
| 490 | + | ||
| 491 | + }); | ||
| 492 | + float voiceTime = tbub.getUserVoiceTime(); | ||
| 493 | + BigDecimal b = new BigDecimal(voiceTime); | ||
| 494 | + float f1 = b.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue(); | ||
| 495 | + holder.voice_time.setText(f1 + "\""); | ||
| 496 | + ViewGroup.LayoutParams lParams = holder.voice_image | ||
| 497 | + .getLayoutParams(); | ||
| 498 | + lParams.width = (int) (mMinItemWith + mMaxItemWith / 60f | ||
| 499 | + * tbub.getUserVoiceTime()); | ||
| 500 | + holder.voice_image.setLayoutParams(lParams); | ||
| 501 | + } | ||
| 502 | + | ||
| 503 | + private void toMsgUserLayout(final ToUserMsgViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 504 | +// holder.headicon.setBackgroundResource(R.mipmap.grzx_tx_s); | ||
| 505 | +// holder.headicon.setImageDrawable(context.getResources() | ||
| 506 | +// .getDrawable(R.mipmap.grzx_tx_s)); | ||
| 507 | + if (!TextUtils.isEmpty(parentUrl)) | ||
| 508 | + GlideUtils.showImg(context,holder.headicon,parentUrl); | ||
| 509 | + else holder.headicon.setImageResource(R.drawable.header_icon); | ||
| 510 | + /* time */ | ||
| 511 | + if (position != 0) { | ||
| 512 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 513 | + .getTime()); | ||
| 514 | + if (showTime != null) { | ||
| 515 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 516 | + holder.chat_time.setText(showTime); | ||
| 517 | + } else { | ||
| 518 | + holder.chat_time.setVisibility(View.GONE); | ||
| 519 | + } | ||
| 520 | + } else { | ||
| 521 | + String showTime = getTime(tbub.getTime(), null); | ||
| 522 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 523 | + holder.chat_time.setText(showTime); | ||
| 524 | + } | ||
| 525 | + | ||
| 526 | + holder.content.setVisibility(View.VISIBLE); | ||
| 527 | + holder.content.setSpanText(handler, tbub.getUserContent(), isGif); | ||
| 528 | + } | ||
| 529 | + | ||
| 530 | + private void toImgUserLayout(final ToUserImgViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 531 | + if (!TextUtils.isEmpty(parentUrl)) | ||
| 532 | + GlideUtils.showImg(context,holder.headicon,parentUrl); | ||
| 533 | + else holder.headicon.setImageResource(R.drawable.header_icon); | ||
| 534 | + switch (tbub.getSendState()) { | ||
| 535 | + case ChatConst.SENDING: | ||
| 536 | + an = AnimationUtils.loadAnimation(context, | ||
| 537 | + R.anim.update_loading_progressbar_anim); | ||
| 538 | + LinearInterpolator lin = new LinearInterpolator(); | ||
| 539 | + an.setInterpolator(lin); | ||
| 540 | + an.setRepeatCount(-1); | ||
| 541 | + holder.sendFailImg | ||
| 542 | + .setBackgroundResource(R.mipmap.xsearch_loading); | ||
| 543 | + holder.sendFailImg.startAnimation(an); | ||
| 544 | + an.startNow(); | ||
| 545 | + holder.sendFailImg.setVisibility(View.VISIBLE); | ||
| 546 | + break; | ||
| 547 | + | ||
| 548 | + case ChatConst.COMPLETED: | ||
| 549 | + holder.sendFailImg.clearAnimation(); | ||
| 550 | + holder.sendFailImg.setVisibility(View.GONE); | ||
| 551 | + break; | ||
| 552 | + | ||
| 553 | + case ChatConst.SENDERROR: | ||
| 554 | + holder.sendFailImg.clearAnimation(); | ||
| 555 | + holder.sendFailImg | ||
| 556 | + .setBackgroundResource(R.mipmap.msg_state_fail_resend_pressed); | ||
| 557 | + holder.sendFailImg.setVisibility(View.VISIBLE); | ||
| 558 | + holder.sendFailImg.setOnClickListener(new View.OnClickListener() { | ||
| 559 | + | ||
| 560 | + @Override | ||
| 561 | + public void onClick(View view) { | ||
| 562 | + // TODO Auto-generated method stub | ||
| 563 | + if (sendErrorListener != null) { | ||
| 564 | + sendErrorListener.onClick(position); | ||
| 565 | + } | ||
| 566 | + } | ||
| 567 | + | ||
| 568 | + }); | ||
| 569 | + break; | ||
| 570 | + default: | ||
| 571 | + break; | ||
| 572 | + } | ||
| 573 | +// holder.headicon.setImageDrawable(context.getResources() | ||
| 574 | +// .getDrawable(R.mipmap.grzx_tx_s)); | ||
| 575 | + | ||
| 576 | + /* time */ | ||
| 577 | + if (position != 0) { | ||
| 578 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 579 | + .getTime()); | ||
| 580 | + if (showTime != null) { | ||
| 581 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 582 | + holder.chat_time.setText(showTime); | ||
| 583 | + } else { | ||
| 584 | + holder.chat_time.setVisibility(View.GONE); | ||
| 585 | + } | ||
| 586 | + } else { | ||
| 587 | + String showTime = getTime(tbub.getTime(), null); | ||
| 588 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 589 | + holder.chat_time.setText(showTime); | ||
| 590 | + } | ||
| 591 | + | ||
| 592 | +// if (isPicRefresh) { | ||
| 593 | + holder.image_group.setVisibility(View.VISIBLE); | ||
| 594 | + final String imageSrc = tbub.getImageLocal() == null ? "" : tbub | ||
| 595 | + .getImageLocal(); | ||
| 596 | + final String imageUrlSrc = tbub.getImageUrl() == null ? "" : tbub | ||
| 597 | + .getImageUrl(); | ||
| 598 | + final String imageIconUrl = tbub.getImageIconUrl() == null ? "" | ||
| 599 | + : tbub.getImageIconUrl(); | ||
| 600 | + File file = new File(imageSrc); | ||
| 601 | + final boolean hasLocal = !imageSrc.equals("") | ||
| 602 | + && FileSaveUtil.isFileExists(file); | ||
| 603 | + int res; | ||
| 604 | + res = R.drawable.chatto_bg_focused; | ||
| 605 | +// Glide.with(context).load(imageSrc).transform(new CustomShapeTransformation(context, res)).into(holder.image_Msg); | ||
| 606 | + Glide.with(context).load(imageSrc).placeholder(R.mipmap.cygs_cs).transform(new CustomShapeTransformation(context, res)).into(holder.image_Msg); | ||
| 607 | + | ||
| 608 | + holder.image_Msg.setOnClickListener(new View.OnClickListener() { | ||
| 609 | + | ||
| 610 | + @Override | ||
| 611 | + public void onClick(View view) { | ||
| 612 | + // TODO Auto-generated method stub | ||
| 613 | + stopPlayVoice(); | ||
| 614 | + Intent intent = new Intent(context, ImageViewActivity.class); | ||
| 615 | + intent.putStringArrayListExtra("images", imageList); | ||
| 616 | + intent.putExtra("clickedIndex", imagePosition.get(position)); | ||
| 617 | + context.startActivity(intent); | ||
| 618 | + } | ||
| 619 | + | ||
| 620 | + }); | ||
| 621 | +// } | ||
| 622 | + } | ||
| 623 | + | ||
| 624 | + private void toVoiceUserLayout(final ToUserVoiceViewHolder holder, final ChatMessageBean tbub, final int position) { | ||
| 625 | + if (!TextUtils.isEmpty(parentUrl)) | ||
| 626 | + GlideUtils.showImg(context,holder.headicon,parentUrl); | ||
| 627 | + else holder.headicon.setImageResource(R.drawable.header_icon); | ||
| 628 | + switch (tbub.getSendState()) { | ||
| 629 | + case ChatConst.SENDING: | ||
| 630 | + an = AnimationUtils.loadAnimation(context, | ||
| 631 | + R.anim.update_loading_progressbar_anim); | ||
| 632 | + LinearInterpolator lin = new LinearInterpolator(); | ||
| 633 | + an.setInterpolator(lin); | ||
| 634 | + an.setRepeatCount(-1); | ||
| 635 | + holder.sendFailImg | ||
| 636 | + .setBackgroundResource(R.mipmap.xsearch_loading); | ||
| 637 | + holder.sendFailImg.startAnimation(an); | ||
| 638 | + an.startNow(); | ||
| 639 | + holder.sendFailImg.setVisibility(View.VISIBLE); | ||
| 640 | + break; | ||
| 641 | + | ||
| 642 | + case ChatConst.COMPLETED: | ||
| 643 | + holder.sendFailImg.clearAnimation(); | ||
| 644 | + holder.sendFailImg.setVisibility(View.GONE); | ||
| 645 | + break; | ||
| 646 | + | ||
| 647 | + case ChatConst.SENDERROR: | ||
| 648 | + holder.sendFailImg.clearAnimation(); | ||
| 649 | + holder.sendFailImg | ||
| 650 | + .setBackgroundResource(R.mipmap.msg_state_fail_resend_pressed); | ||
| 651 | + holder.sendFailImg.setVisibility(View.VISIBLE); | ||
| 652 | + holder.sendFailImg.setOnClickListener(new View.OnClickListener() { | ||
| 653 | + | ||
| 654 | + @Override | ||
| 655 | + public void onClick(View view) { | ||
| 656 | + // TODO Auto-generated method stub | ||
| 657 | + if (sendErrorListener != null) { | ||
| 658 | + sendErrorListener.onClick(position); | ||
| 659 | + } | ||
| 660 | + } | ||
| 661 | + | ||
| 662 | + }); | ||
| 663 | + break; | ||
| 664 | + default: | ||
| 665 | + break; | ||
| 666 | + } | ||
| 667 | +// holder.headicon.setImageDrawable(context.getResources() | ||
| 668 | +// .getDrawable(R.mipmap.grzx_tx_s)); | ||
| 669 | + | ||
| 670 | + /* time */ | ||
| 671 | + if (position != 0) { | ||
| 672 | + String showTime = getTime(tbub.getTime(), userList.get(position - 1) | ||
| 673 | + .getTime()); | ||
| 674 | + if (showTime != null) { | ||
| 675 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 676 | + holder.chat_time.setText(showTime); | ||
| 677 | + } else { | ||
| 678 | + holder.chat_time.setVisibility(View.GONE); | ||
| 679 | + } | ||
| 680 | + } else { | ||
| 681 | + String showTime = getTime(tbub.getTime(), null); | ||
| 682 | + holder.chat_time.setVisibility(View.VISIBLE); | ||
| 683 | + holder.chat_time.setText(showTime); | ||
| 684 | + } | ||
| 685 | + holder.voice_group.setVisibility(View.VISIBLE); | ||
| 686 | + if (holder.receiver_voice_unread != null) | ||
| 687 | + holder.receiver_voice_unread.setVisibility(View.GONE); | ||
| 688 | + if (holder.receiver_voice_unread != null && unReadPosition != null) { | ||
| 689 | + for (String unRead : unReadPosition) { | ||
| 690 | + if (unRead.equals(position + "")) { | ||
| 691 | + holder.receiver_voice_unread | ||
| 692 | + .setVisibility(View.VISIBLE); | ||
| 693 | + break; | ||
| 694 | + } | ||
| 695 | + } | ||
| 696 | + } | ||
| 697 | + AnimationDrawable drawable; | ||
| 698 | + holder.voice_anim.setId(position); | ||
| 699 | + if (position == voicePlayPosition) { | ||
| 700 | + holder.voice_anim.setBackgroundResource(R.mipmap.adj); | ||
| 701 | + holder.voice_anim | ||
| 702 | + .setBackgroundResource(R.drawable.voice_play_send); | ||
| 703 | + drawable = (AnimationDrawable) holder.voice_anim | ||
| 704 | + .getBackground(); | ||
| 705 | + drawable.start(); | ||
| 706 | + } else { | ||
| 707 | + holder.voice_anim.setBackgroundResource(R.mipmap.adj); | ||
| 708 | + } | ||
| 709 | + holder.voice_group.setOnClickListener(new View.OnClickListener() { | ||
| 710 | + | ||
| 711 | + @Override | ||
| 712 | + public void onClick(View v) { | ||
| 713 | + // TODO Auto-generated method stub | ||
| 714 | + if (holder.receiver_voice_unread != null) | ||
| 715 | + holder.receiver_voice_unread.setVisibility(View.GONE); | ||
| 716 | + holder.voice_anim.setBackgroundResource(R.mipmap.adj); | ||
| 717 | + stopPlayVoice(); | ||
| 718 | + voicePlayPosition = holder.voice_anim.getId(); | ||
| 719 | + AnimationDrawable drawable; | ||
| 720 | + holder.voice_anim | ||
| 721 | + .setBackgroundResource(R.drawable.voice_play_send); | ||
| 722 | + drawable = (AnimationDrawable) holder.voice_anim | ||
| 723 | + .getBackground(); | ||
| 724 | + drawable.start(); | ||
| 725 | + String voicePath = tbub.getUserVoiceUrl() == null ? "" | ||
| 726 | + : tbub.getUserVoiceUrl(); | ||
| 727 | + if (voiceIsRead != null) { | ||
| 728 | + voiceIsRead.voiceOnClick(position); | ||
| 729 | + } | ||
| 730 | + MediaManager.playSound(voicePath, | ||
| 731 | + new MediaPlayer.OnCompletionListener() { | ||
| 732 | + | ||
| 733 | + @Override | ||
| 734 | + public void onCompletion(MediaPlayer mp) { | ||
| 735 | + voicePlayPosition = -1; | ||
| 736 | + holder.voice_anim | ||
| 737 | + .setBackgroundResource(R.mipmap.adj); | ||
| 738 | + } | ||
| 739 | + }); | ||
| 740 | + } | ||
| 741 | + | ||
| 742 | + }); | ||
| 743 | + float voiceTime = tbub.getUserVoiceTime(); | ||
| 744 | + BigDecimal b = new BigDecimal(voiceTime); | ||
| 745 | + float f1 = b.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue(); | ||
| 746 | + holder.voice_time.setText(f1 + "\""); | ||
| 747 | + ViewGroup.LayoutParams lParams = holder.voice_image | ||
| 748 | + .getLayoutParams(); | ||
| 749 | + lParams.width = (int) (mMinItemWith + mMaxItemWith / 60f | ||
| 750 | + * tbub.getUserVoiceTime()); | ||
| 751 | + holder.voice_image.setLayoutParams(lParams); | ||
| 752 | + } | ||
| 753 | + | ||
| 754 | + @SuppressLint("SimpleDateFormat") | ||
| 755 | + public String getTime(String time, String before) { | ||
| 756 | + String show_time = null; | ||
| 757 | + if (before != null) { | ||
| 758 | + try { | ||
| 759 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 760 | + java.util.Date now = df.parse(time); | ||
| 761 | + java.util.Date date = df.parse(before); | ||
| 762 | + long l = now.getTime() - date.getTime(); | ||
| 763 | + long day = l / (24 * 60 * 60 * 1000); | ||
| 764 | + long hour = (l / (60 * 60 * 1000) - day * 24); | ||
| 765 | + long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60); | ||
| 766 | + if (min >= 1) { | ||
| 767 | + show_time = time.substring(11); | ||
| 768 | + } | ||
| 769 | + } catch (Exception e) { | ||
| 770 | + e.printStackTrace(); | ||
| 771 | + } | ||
| 772 | + } else { | ||
| 773 | + show_time = time.substring(11); | ||
| 774 | + } | ||
| 775 | + String getDay = getDay(time); | ||
| 776 | + if (show_time != null && getDay != null) | ||
| 777 | + show_time = getDay + " " + show_time; | ||
| 778 | + return show_time; | ||
| 779 | + } | ||
| 780 | + | ||
| 781 | + @SuppressLint("SimpleDateFormat") | ||
| 782 | + public static String returnTime() { | ||
| 783 | + SimpleDateFormat sDateFormat = new SimpleDateFormat( | ||
| 784 | + "yyyy-MM-dd HH:mm:ss"); | ||
| 785 | + String date = sDateFormat.format(new java.util.Date()); | ||
| 786 | + return date; | ||
| 787 | + } | ||
| 788 | + | ||
| 789 | + @SuppressLint("SimpleDateFormat") | ||
| 790 | + public String getDay(String time) { | ||
| 791 | + String showDay = null; | ||
| 792 | + String nowTime = returnTime(); | ||
| 793 | + try { | ||
| 794 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 795 | + java.util.Date now = df.parse(nowTime); | ||
| 796 | + java.util.Date date = df.parse(time); | ||
| 797 | + long l = now.getTime() - date.getTime(); | ||
| 798 | + long day = l / (24 * 60 * 60 * 1000); | ||
| 799 | + if (day >= 365) { | ||
| 800 | + showDay = time.substring(0, 10); | ||
| 801 | + } else if (day >= 1 && day < 365) { | ||
| 802 | + showDay = time.substring(5, 10); | ||
| 803 | + } | ||
| 804 | + } catch (Exception e) { | ||
| 805 | + e.printStackTrace(); | ||
| 806 | + } | ||
| 807 | + return showDay; | ||
| 808 | + } | ||
| 809 | + | ||
| 810 | + public static Bitmap getLoacalBitmap(String url) { | ||
| 811 | + try { | ||
| 812 | + ByteArrayOutputStream out; | ||
| 813 | + FileInputStream fis = new FileInputStream(url); | ||
| 814 | + BufferedInputStream bis = new BufferedInputStream(fis); | ||
| 815 | + out = new ByteArrayOutputStream(); | ||
| 816 | + @SuppressWarnings("unused") | ||
| 817 | + int hasRead = 0; | ||
| 818 | + byte[] buffer = new byte[1024 * 2]; | ||
| 819 | + while ((hasRead = bis.read(buffer)) > 0) { | ||
| 820 | + // 读出多少数据,向输出流中写入多少 | ||
| 821 | + out.write(buffer); | ||
| 822 | + out.flush(); | ||
| 823 | + } | ||
| 824 | + out.close(); | ||
| 825 | + fis.close(); | ||
| 826 | + bis.close(); | ||
| 827 | + byte[] data = out.toByteArray(); | ||
| 828 | + // 长宽减半 | ||
| 829 | + BitmapFactory.Options opts = new BitmapFactory.Options(); | ||
| 830 | + opts.inSampleSize = 3; | ||
| 831 | + return BitmapFactory.decodeByteArray(data, 0, data.length, opts); | ||
| 832 | + } catch (FileNotFoundException e) { | ||
| 833 | + e.printStackTrace(); | ||
| 834 | + return null; | ||
| 835 | + } catch (IOException e) { | ||
| 836 | + // TODO Auto-generated catch block | ||
| 837 | + e.printStackTrace(); | ||
| 838 | + return null; | ||
| 839 | + } | ||
| 840 | + } | ||
| 841 | + | ||
| 842 | + public void stopPlayVoice() { | ||
| 843 | + if (voicePlayPosition != -1) { | ||
| 844 | + View voicePlay = (View) ((Activity) context) | ||
| 845 | + .findViewById(voicePlayPosition); | ||
| 846 | + if (voicePlay != null) { | ||
| 847 | + if (getItemViewType(voicePlayPosition) == FROM_USER_VOICE) { | ||
| 848 | + voicePlay | ||
| 849 | + .setBackgroundResource(R.mipmap.receiver_voice_node_playing003); | ||
| 850 | + } else { | ||
| 851 | + voicePlay.setBackgroundResource(R.mipmap.adj); | ||
| 852 | + } | ||
| 853 | + } | ||
| 854 | + MediaManager.pause(); | ||
| 855 | + voicePlayPosition = -1; | ||
| 856 | + } | ||
| 857 | + } | ||
| 858 | +} |
app/src/main/java/com/shunzhi/parent/ui/activity/chartroom/fragment/ImageViewFragment.java
0 → 100644
| @@ -0,0 +1,71 @@ | @@ -0,0 +1,71 @@ | ||
| 1 | +package com.shunzhi.parent.ui.activity.chartroom.fragment; | ||
| 2 | + | ||
| 3 | +import android.graphics.Bitmap; | ||
| 4 | +import android.graphics.BitmapFactory; | ||
| 5 | +import android.support.v4.app.Fragment; | ||
| 6 | +import android.view.View; | ||
| 7 | +import android.view.View.OnClickListener; | ||
| 8 | +import android.widget.ProgressBar; | ||
| 9 | + | ||
| 10 | +import com.bumptech.glide.Glide; | ||
| 11 | +import com.bumptech.glide.request.animation.GlideAnimation; | ||
| 12 | +import com.bumptech.glide.request.target.SimpleTarget; | ||
| 13 | +import com.polites.android.GestureImageView; | ||
| 14 | +import com.shunzhi.parent.R; | ||
| 15 | + | ||
| 16 | +public class ImageViewFragment extends Fragment { | ||
| 17 | + private String imageUrl; | ||
| 18 | + private ProgressBar loadBar; | ||
| 19 | + private GestureImageView imageGiv; | ||
| 20 | + | ||
| 21 | + public View onCreateView(android.view.LayoutInflater inflater, | ||
| 22 | + android.view.ViewGroup container, | ||
| 23 | + android.os.Bundle savedInstanceState) { | ||
| 24 | + View view = inflater.inflate(R.layout.layout_images_view_item, container, | ||
| 25 | + false); | ||
| 26 | + init(view); | ||
| 27 | + loadImage(imageUrl); | ||
| 28 | + return view; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + private void init(View mView) { | ||
| 32 | + loadBar = (ProgressBar) mView.findViewById(R.id.imageView_loading_pb); | ||
| 33 | + imageGiv = (GestureImageView) mView | ||
| 34 | + .findViewById(R.id.imageView_item_giv); | ||
| 35 | + imageGiv.setOnClickListener(new OnClickListener() { | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void onClick(View v) { | ||
| 39 | + getActivity().finish(); | ||
| 40 | + } | ||
| 41 | + }); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public void loadImage(String url) { | ||
| 45 | + if (url.startsWith("http://")) { | ||
| 46 | + Glide.with(this).load(url).asBitmap().into(new SimpleTarget<Bitmap>() { | ||
| 47 | + @Override | ||
| 48 | + public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { | ||
| 49 | + if (resource != null) { | ||
| 50 | + imageGiv.setImageBitmap(resource); | ||
| 51 | + loadBar.setVisibility(View.GONE); | ||
| 52 | + imageGiv.setVisibility(View.VISIBLE); | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + }); | ||
| 56 | + } else { | ||
| 57 | + imageGiv.setImageBitmap(BitmapFactory.decodeFile(url)); | ||
| 58 | + loadBar.setVisibility(View.GONE); | ||
| 59 | + imageGiv.setVisibility(View.VISIBLE); | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public String getImageUrl() { | ||
| 64 | + return imageUrl; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public void setImageUrl(String imageUrl) { | ||
| 68 | + this.imageUrl = imageUrl; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | +} |
app/src/main/java/com/shunzhi/parent/ui/activity/message/LeaverMessagesActivity.java
0 → 100644
| @@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
| 1 | +package com.shunzhi.parent.ui.activity.message; | ||
| 2 | + | ||
| 3 | +import android.content.Intent; | ||
| 4 | +import android.support.annotation.NonNull; | ||
| 5 | +import android.support.v7.app.AppCompatActivity; | ||
| 6 | +import android.os.Bundle; | ||
| 7 | + | ||
| 8 | +import com.share.mvpsdk.base.BasePresenter; | ||
| 9 | +import com.share.mvpsdk.base.activity.BaseMVPCompatActivity; | ||
| 10 | +import com.shunzhi.parent.R; | ||
| 11 | +import com.shunzhi.parent.contract.leavermessage.LeaverMessage; | ||
| 12 | +import com.shunzhi.parent.contract.leavermessage.LeaverMessageContract; | ||
| 13 | +import com.shunzhi.parent.presenter.leavermessage.LeaverMessagePresenter; | ||
| 14 | +import com.shunzhi.parent.ui.activity.chartroom.RecyclerViewChatActivity; | ||
| 15 | + | ||
| 16 | +import java.util.List; | ||
| 17 | + | ||
| 18 | +public class LeaverMessagesActivity extends BaseMVPCompatActivity<LeaverMessageContract.MyLeaverMessagePresenter,LeaverMessageContract.ILeaverMessageModel> | ||
| 19 | +implements LeaverMessageContract.ILeverMessageView{ | ||
| 20 | + | ||
| 21 | + @Override | ||
| 22 | + protected void initView(Bundle savedInstanceState) { | ||
| 23 | + Intent intent = new Intent(this, RecyclerViewChatActivity.class); | ||
| 24 | + startActivity(intent); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @Override | ||
| 28 | + protected int getLayoutId() { | ||
| 29 | + return R.layout.activity_leaver_messages; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + @NonNull | ||
| 33 | + @Override | ||
| 34 | + public BasePresenter initPresenter() { | ||
| 35 | + return LeaverMessagePresenter.newInstance(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @Override | ||
| 39 | + public void ShowLeaverMessageList(List<LeaverMessage> leaverMessageList) { | ||
| 40 | + | ||
| 41 | + } | ||
| 42 | +} |
app/src/main/java/com/shunzhi/parent/ui/fragment/report/ChengZhangFragment.java
| @@ -40,6 +40,7 @@ import com.shunzhi.parent.ui.activity.BankActivity; | @@ -40,6 +40,7 @@ import com.shunzhi.parent.ui.activity.BankActivity; | ||
| 40 | import com.shunzhi.parent.ui.activity.MyChildActivity; | 40 | import com.shunzhi.parent.ui.activity.MyChildActivity; |
| 41 | import com.shunzhi.parent.ui.activity.apply.ApplyReplaceCardActivity; | 41 | import com.shunzhi.parent.ui.activity.apply.ApplyReplaceCardActivity; |
| 42 | import com.shunzhi.parent.ui.activity.apply.ApplySigninActivity; | 42 | import com.shunzhi.parent.ui.activity.apply.ApplySigninActivity; |
| 43 | +import com.shunzhi.parent.ui.activity.chartroom.RecyclerViewChatActivity; | ||
| 43 | import com.shunzhi.parent.ui.activity.mywebview.WebViewActivity; | 44 | import com.shunzhi.parent.ui.activity.mywebview.WebViewActivity; |
| 44 | 45 | ||
| 45 | import java.util.List; | 46 | import java.util.List; |
| @@ -82,7 +83,7 @@ public class ChengZhangFragment extends BaseMVPCompatFragment<ReportContract.Rep | @@ -82,7 +83,7 @@ public class ChengZhangFragment extends BaseMVPCompatFragment<ReportContract.Rep | ||
| 82 | 83 | ||
| 83 | private String type = "", jsonStr = ""; | 84 | private String type = "", jsonStr = ""; |
| 84 | 85 | ||
| 85 | - LinearLayout layout_chengzhang, layout_report, layout_kaoqin, layout_buka, layout_qingjia; | 86 | + LinearLayout layout_chengzhang, layout_report, layout_kaoqin, layout_buka, layout_qingjia,layout_liuyan; |
| 86 | 87 | ||
| 87 | RelativeLayout rl_noData; | 88 | RelativeLayout rl_noData; |
| 88 | 89 | ||
| @@ -101,6 +102,7 @@ public class ChengZhangFragment extends BaseMVPCompatFragment<ReportContract.Rep | @@ -101,6 +102,7 @@ public class ChengZhangFragment extends BaseMVPCompatFragment<ReportContract.Rep | ||
| 101 | layout_kaoqin = view.findViewById(R.id.layout_kaoqin); | 102 | layout_kaoqin = view.findViewById(R.id.layout_kaoqin); |
| 102 | layout_buka = view.findViewById(R.id.layout_buka); | 103 | layout_buka = view.findViewById(R.id.layout_buka); |
| 103 | layout_qingjia = view.findViewById(R.id.layout_qingjia); | 104 | layout_qingjia = view.findViewById(R.id.layout_qingjia); |
| 105 | + layout_liuyan=view.findViewById(R.id.layout_liuyan); | ||
| 104 | tvNoData = view.findViewById(R.id.tvNoData); | 106 | tvNoData = view.findViewById(R.id.tvNoData); |
| 105 | calendarView_month_mode = view.findViewById(R.id.calendarView_month_mode); | 107 | calendarView_month_mode = view.findViewById(R.id.calendarView_month_mode); |
| 106 | monthWeekMaterialCalendarView = view.findViewById(R.id.slidelayout); | 108 | monthWeekMaterialCalendarView = view.findViewById(R.id.slidelayout); |
| @@ -108,6 +110,7 @@ public class ChengZhangFragment extends BaseMVPCompatFragment<ReportContract.Rep | @@ -108,6 +110,7 @@ public class ChengZhangFragment extends BaseMVPCompatFragment<ReportContract.Rep | ||
| 108 | layout_kaoqin.setOnClickListener(this); | 110 | layout_kaoqin.setOnClickListener(this); |
| 109 | layout_buka.setOnClickListener(this); | 111 | layout_buka.setOnClickListener(this); |
| 110 | layout_qingjia.setOnClickListener(this); | 112 | layout_qingjia.setOnClickListener(this); |
| 113 | + layout_liuyan.setOnClickListener(this); | ||
| 111 | type = getArguments().getString("type"); | 114 | type = getArguments().getString("type"); |
| 112 | jsonStr = getArguments().getString("jsonStr"); | 115 | jsonStr = getArguments().getString("jsonStr"); |
| 113 | show(); | 116 | show(); |
| @@ -200,6 +203,13 @@ public class ChengZhangFragment extends BaseMVPCompatFragment<ReportContract.Rep | @@ -200,6 +203,13 @@ public class ChengZhangFragment extends BaseMVPCompatFragment<ReportContract.Rep | ||
| 200 | case R.id.layout_qingjia: | 203 | case R.id.layout_qingjia: |
| 201 | ToastUtils.showToast("正在努力开发中,敬请期待"); | 204 | ToastUtils.showToast("正在努力开发中,敬请期待"); |
| 202 | break; | 205 | break; |
| 206 | + case R.id.layout_liuyan://留言 | ||
| 207 | + Bundle bundle = new Bundle(); | ||
| 208 | + bundle.putString("childName",childBean.getStudentName()); | ||
| 209 | + bundle.putString("childPhoto",childBean.getPhoto()); | ||
| 210 | + startNewActivity(RecyclerViewChatActivity.class,bundle); | ||
| 211 | +// startActivity(new Intent(getActivity(),RecyclerViewChatActivity.class)); | ||
| 212 | + break; | ||
| 203 | } | 213 | } |
| 204 | } | 214 | } |
| 205 | 215 |
app/src/main/res/anim/update_loading_progressbar_anim.xml
0 → 100644
| @@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<rotate xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:drawable="@mipmap/xsearch_loading" | ||
| 4 | + android:fromDegrees="0" | ||
| 5 | + android:toDegrees="359" | ||
| 6 | + android:pivotX="50%" | ||
| 7 | + android:pivotY="50%" | ||
| 8 | + android:duration="700" | ||
| 9 | + /> | ||
| 0 | \ No newline at end of file | 10 | \ No newline at end of file |
903 Bytes
1 KB
135 Bytes
| @@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <solid android:color="@android:color/white" /> | ||
| 4 | + | ||
| 5 | + <stroke | ||
| 6 | + android:width="1dp" | ||
| 7 | + android:color="@color/light_gray_2" /> | ||
| 8 | + | ||
| 9 | + <padding | ||
| 10 | + android:bottom="1dp" | ||
| 11 | + android:left="1dp" | ||
| 12 | + android:right="1dp" | ||
| 13 | + android:top="1dp" /> | ||
| 14 | + <!-- | ||
| 15 | + <corners android:topLeftRadius="5dp" android:topRightRadius="5dp" | ||
| 16 | + android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp"/> --> | ||
| 17 | +</shape> | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |
| @@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + | ||
| 4 | + <item android:state_pressed="true"><shape android:shape="rectangle"> | ||
| 5 | + <solid android:color="@color/light_blue2" /> | ||
| 6 | + | ||
| 7 | + <stroke android:width="1dp" android:color="@color/light_blue2" /> | ||
| 8 | + | ||
| 9 | + <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" /> | ||
| 10 | + | ||
| 11 | + <corners android:radius="2dp" /> | ||
| 12 | + </shape></item> | ||
| 13 | + <item android:state_focused="true"><shape android:shape="rectangle"> | ||
| 14 | + <solid android:color="@color/light_blue2" /> | ||
| 15 | + | ||
| 16 | + <stroke android:width="1dp" android:color="@color/light_blue2" /> | ||
| 17 | + | ||
| 18 | + <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" /> | ||
| 19 | + | ||
| 20 | + <corners android:radius="2dp" /> | ||
| 21 | + </shape></item> | ||
| 22 | + <item><shape android:shape="rectangle"> | ||
| 23 | + <solid android:color="@color/light_blue1" /> | ||
| 24 | + | ||
| 25 | + <stroke android:width="1dp" android:color="@color/light_blue1" /> | ||
| 26 | + | ||
| 27 | + <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" /> | ||
| 28 | + | ||
| 29 | + <corners android:radius="2dp" /> | ||
| 30 | + </shape></item> | ||
| 31 | + | ||
| 32 | +</selector> | ||
| 0 | \ No newline at end of file | 33 | \ No newline at end of file |
| @@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<animation-list xmlns:android="http://schemas.android.com/apk/res/android" > | ||
| 3 | + | ||
| 4 | + <item | ||
| 5 | + android:drawable="@mipmap/receiver_voice_node_playing000" | ||
| 6 | + android:duration="300"> | ||
| 7 | + </item> | ||
| 8 | + | ||
| 9 | + <item | ||
| 10 | + android:drawable="@mipmap/receiver_voice_node_playing001" | ||
| 11 | + android:duration="300"> | ||
| 12 | + </item> | ||
| 13 | + | ||
| 14 | + <item | ||
| 15 | + android:drawable="@mipmap/receiver_voice_node_playing002" | ||
| 16 | + android:duration="300"> | ||
| 17 | + </item> | ||
| 18 | + | ||
| 19 | + <item | ||
| 20 | + android:drawable="@mipmap/receiver_voice_node_playing003" | ||
| 21 | + android:duration="300"> | ||
| 22 | + </item> | ||
| 23 | + | ||
| 24 | +</animation-list> | ||
| 0 | \ No newline at end of file | 25 | \ No newline at end of file |
| @@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<animation-list xmlns:android="http://schemas.android.com/apk/res/android" > | ||
| 3 | + | ||
| 4 | + <item | ||
| 5 | + android:drawable="@mipmap/v_anim1" | ||
| 6 | + android:duration="300"> | ||
| 7 | + </item> | ||
| 8 | + | ||
| 9 | + <item | ||
| 10 | + android:drawable="@mipmap/v_anim2" | ||
| 11 | + android:duration="300"> | ||
| 12 | + </item> | ||
| 13 | + | ||
| 14 | + <item | ||
| 15 | + android:drawable="@mipmap/v_anim3" | ||
| 16 | + android:duration="300"> | ||
| 17 | + </item> | ||
| 18 | + | ||
| 19 | +</animation-list> | ||
| 0 | \ No newline at end of file | 20 | \ No newline at end of file |
| @@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="match_parent" | ||
| 5 | + android:orientation="vertical" > | ||
| 6 | + <android.support.v4.view.ViewPager | ||
| 7 | + android:id="@+id/images_vp" | ||
| 8 | + android:layout_width="wrap_content" | ||
| 9 | + android:layout_height="wrap_content"> | ||
| 10 | + | ||
| 11 | + </android.support.v4.view.ViewPager> | ||
| 12 | + <LinearLayout | ||
| 13 | + android:id="@+id/imageView_title_ll" | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="wrap_content" | ||
| 16 | + android:layout_alignParentTop="true" | ||
| 17 | + android:orientation="horizontal" | ||
| 18 | + android:background="@color/zz_half_transparent" | ||
| 19 | + android:paddingTop="5dp" | ||
| 20 | + android:paddingBottom="5dp" | ||
| 21 | + android:gravity="center"> | ||
| 22 | + <TextView | ||
| 23 | + android:id="@+id/imageView_current_tv" | ||
| 24 | + android:layout_width="wrap_content" | ||
| 25 | + android:layout_height="wrap_content" | ||
| 26 | + android:text="1" | ||
| 27 | + android:textSize="18sp" | ||
| 28 | + android:textColor="@color/white"/> | ||
| 29 | + <TextView | ||
| 30 | + android:id="@+id/imageView_total_tv" | ||
| 31 | + android:layout_width="wrap_content" | ||
| 32 | + android:layout_height="wrap_content" | ||
| 33 | + android:text="/8" | ||
| 34 | + android:textSize="18sp" | ||
| 35 | + android:textColor="@color/white"/> | ||
| 36 | + </LinearLayout> | ||
| 37 | +</RelativeLayout> |
| @@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="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="match_parent" | ||
| 7 | + tools:context=".ui.activity.message.LeaverMessagesActivity"> | ||
| 8 | + | ||
| 9 | +</android.support.constraint.ConstraintLayout> | ||
| 0 | \ No newline at end of file | 10 | \ No newline at end of file |
app/src/main/res/layout/layout_chengzhang.xml
| @@ -105,4 +105,43 @@ | @@ -105,4 +105,43 @@ | ||
| 105 | 105 | ||
| 106 | </LinearLayout> | 106 | </LinearLayout> |
| 107 | 107 | ||
| 108 | + | ||
| 109 | + <TextView | ||
| 110 | + android:layout_width="wrap_content" | ||
| 111 | + android:layout_height="wrap_content" | ||
| 112 | + android:layout_gravity="center_horizontal" | ||
| 113 | + android:layout_marginTop="@dimen/size_dp_10" | ||
| 114 | + android:text="云视窗" | ||
| 115 | + android:textColor="@color/textColor" | ||
| 116 | + android:textSize="@dimen/size_dp_16" /> | ||
| 117 | + | ||
| 118 | + <LinearLayout | ||
| 119 | + android:id="@+id/layout_liuyan" | ||
| 120 | + android:layout_width="match_parent" | ||
| 121 | + android:layout_height="?android:actionBarSize" | ||
| 122 | + android:layout_marginLeft="@dimen/size_dp_10" | ||
| 123 | + android:layout_marginRight="@dimen/size_dp_10" | ||
| 124 | + android:layout_marginTop="@dimen/size_dp_10" | ||
| 125 | + android:background="@drawable/shape_corner_bg" | ||
| 126 | + android:orientation="horizontal"> | ||
| 127 | + | ||
| 128 | + <ImageView | ||
| 129 | + android:layout_width="wrap_content" | ||
| 130 | + android:layout_height="wrap_content" | ||
| 131 | + android:layout_gravity="center_vertical" | ||
| 132 | + android:layout_margin="@dimen/size_dp_5" | ||
| 133 | + android:scaleType="fitXY" | ||
| 134 | + android:src="@drawable/kaoqin" /> | ||
| 135 | + | ||
| 136 | + <TextView | ||
| 137 | + android:layout_width="wrap_content" | ||
| 138 | + android:layout_height="wrap_content" | ||
| 139 | + android:layout_gravity="center_vertical" | ||
| 140 | + android:layout_marginLeft="@dimen/size_dp_15" | ||
| 141 | + android:text="留言板" | ||
| 142 | + android:textColor="@color/textColor" | ||
| 143 | + android:textSize="@dimen/size_dp_16" /> | ||
| 144 | + | ||
| 145 | + </LinearLayout> | ||
| 146 | + | ||
| 108 | </LinearLayout> | 147 | </LinearLayout> |
| 109 | \ No newline at end of file | 148 | \ No newline at end of file |
| @@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="wrap_content" | ||
| 4 | + android:layout_height="wrap_content" | ||
| 5 | + android:padding="5dp"> | ||
| 6 | + | ||
| 7 | + <TextView | ||
| 8 | + android:id="@+id/chat_time" | ||
| 9 | + android:layout_width="wrap_content" | ||
| 10 | + android:layout_height="wrap_content" | ||
| 11 | + android:layout_alignParentTop="true" | ||
| 12 | + android:layout_centerHorizontal="true" | ||
| 13 | + android:textColor="@color/light_gray_6" | ||
| 14 | + android:textSize="10sp" | ||
| 15 | + android:visibility="gone" /> | ||
| 16 | + | ||
| 17 | + <ImageView | ||
| 18 | + android:id="@+id/tb_other_user_icon" | ||
| 19 | + android:layout_width="50dp" | ||
| 20 | + android:layout_height="50dp" | ||
| 21 | + android:layout_alignParentLeft="true" | ||
| 22 | + android:layout_below="@id/chat_time" /> | ||
| 23 | + | ||
| 24 | + <LinearLayout | ||
| 25 | + android:layout_width="wrap_content" | ||
| 26 | + android:layout_height="wrap_content" | ||
| 27 | + android:layout_below="@id/chat_time" | ||
| 28 | + android:layout_margin="5dp" | ||
| 29 | + android:layout_toRightOf="@+id/tb_other_user_icon" | ||
| 30 | + android:orientation="horizontal"> | ||
| 31 | + | ||
| 32 | + <com.shunzhi.mychartlibrary.widget.BubbleImageView | ||
| 33 | + android:id="@+id/image_message" | ||
| 34 | + android:layout_width="wrap_content" | ||
| 35 | + android:layout_height="wrap_content" | ||
| 36 | + android:scaleType="centerCrop" /> | ||
| 37 | + </LinearLayout> | ||
| 38 | + | ||
| 39 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 40 | \ No newline at end of file |
| @@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout | ||
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | + xmlns:gesture-image="http://schemas.polites.com/android" | ||
| 5 | + android:id="@+id/image_view_rl" | ||
| 6 | + android:layout_width="fill_parent" | ||
| 7 | + android:layout_height="fill_parent" | ||
| 8 | + android:orientation="vertical" | ||
| 9 | + android:background="@color/zz_half_transparent"> | ||
| 10 | + | ||
| 11 | + <ProgressBar | ||
| 12 | + android:id="@+id/imageView_loading_pb" | ||
| 13 | + android:layout_width="wrap_content" | ||
| 14 | + android:layout_height="wrap_content" | ||
| 15 | + android:layout_centerInParent="true" | ||
| 16 | + /> | ||
| 17 | + | ||
| 18 | + <com.polites.android.GestureImageView | ||
| 19 | + android:id="@+id/imageView_item_giv" | ||
| 20 | + android:layout_width="fill_parent" | ||
| 21 | + android:layout_height="fill_parent" | ||
| 22 | + gesture-image:min-scale="0.75" | ||
| 23 | + gesture-image:max-scale="10.0" | ||
| 24 | + android:visibility="gone"/> | ||
| 25 | +</RelativeLayout> |
| @@ -0,0 +1,54 @@ | @@ -0,0 +1,54 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="wrap_content" | ||
| 4 | + android:layout_height="wrap_content" | ||
| 5 | + android:padding="5dp"> | ||
| 6 | + | ||
| 7 | + <TextView | ||
| 8 | + android:id="@+id/mychat_time" | ||
| 9 | + android:layout_width="wrap_content" | ||
| 10 | + android:layout_height="wrap_content" | ||
| 11 | + android:layout_alignParentTop="true" | ||
| 12 | + android:layout_centerHorizontal="true" | ||
| 13 | + android:textColor="@color/light_gray_6" | ||
| 14 | + android:textSize="10sp" | ||
| 15 | + android:visibility="gone" /> | ||
| 16 | + | ||
| 17 | + <ImageView | ||
| 18 | + android:id="@+id/tb_my_user_icon" | ||
| 19 | + android:layout_width="50dp" | ||
| 20 | + android:layout_height="50dp" | ||
| 21 | + android:layout_alignParentRight="true" | ||
| 22 | + android:layout_below="@id/mychat_time" /> | ||
| 23 | + | ||
| 24 | + <LinearLayout | ||
| 25 | + android:layout_width="wrap_content" | ||
| 26 | + android:layout_height="wrap_content" | ||
| 27 | + android:layout_below="@id/mychat_time" | ||
| 28 | + android:layout_toLeftOf="@+id/tb_my_user_icon" | ||
| 29 | + android:orientation="horizontal"> | ||
| 30 | + | ||
| 31 | + <ImageView | ||
| 32 | + android:id="@+id/mysend_fail_img" | ||
| 33 | + android:layout_width="25dp" | ||
| 34 | + android:layout_height="25dp" | ||
| 35 | + android:layout_gravity="center_vertical" | ||
| 36 | + android:background="@mipmap/msg_state_fail_resend_pressed" /> | ||
| 37 | + | ||
| 38 | + <LinearLayout | ||
| 39 | + android:id="@+id/image_group" | ||
| 40 | + android:layout_width="wrap_content" | ||
| 41 | + android:layout_height="wrap_content" | ||
| 42 | + android:layout_margin="5dp" | ||
| 43 | + android:orientation="vertical" | ||
| 44 | + android:visibility="gone"> | ||
| 45 | + | ||
| 46 | + <com.shunzhi.mychartlibrary.widget.BubbleImageView | ||
| 47 | + android:id="@+id/image_message" | ||
| 48 | + android:layout_width="wrap_content" | ||
| 49 | + android:layout_height="wrap_content" | ||
| 50 | + android:scaleType="centerCrop" /> | ||
| 51 | + </LinearLayout> | ||
| 52 | + </LinearLayout> | ||
| 53 | + | ||
| 54 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 55 | \ No newline at end of file |
| @@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="wrap_content" | ||
| 4 | + android:layout_height="wrap_content" | ||
| 5 | + android:padding="5dp"> | ||
| 6 | + | ||
| 7 | + <TextView | ||
| 8 | + android:id="@+id/chat_time" | ||
| 9 | + android:layout_width="wrap_content" | ||
| 10 | + android:layout_height="wrap_content" | ||
| 11 | + android:layout_alignParentTop="true" | ||
| 12 | + android:layout_centerHorizontal="true" | ||
| 13 | + android:textColor="@color/light_gray_6" | ||
| 14 | + android:textSize="10sp" | ||
| 15 | + android:visibility="gone" /> | ||
| 16 | + | ||
| 17 | + <ImageView | ||
| 18 | + android:id="@+id/tb_other_user_icon" | ||
| 19 | + android:layout_width="50dp" | ||
| 20 | + android:layout_height="50dp" | ||
| 21 | + android:layout_alignParentLeft="true" | ||
| 22 | + android:layout_below="@id/chat_time" /> | ||
| 23 | + | ||
| 24 | + <LinearLayout | ||
| 25 | + android:layout_width="wrap_content" | ||
| 26 | + android:layout_height="wrap_content" | ||
| 27 | + android:layout_below="@id/chat_time" | ||
| 28 | + android:layout_toRightOf="@+id/tb_other_user_icon" | ||
| 29 | + android:orientation="horizontal"> | ||
| 30 | + | ||
| 31 | + <com.shunzhi.mychartlibrary.widget.GifTextView | ||
| 32 | + android:id="@+id/content" | ||
| 33 | + android:layout_width="wrap_content" | ||
| 34 | + android:layout_height="wrap_content" | ||
| 35 | + android:layout_margin="5dp" | ||
| 36 | + android:background="@drawable/chatfrom_bg_focused" | ||
| 37 | + android:textSize="16sp" /> | ||
| 38 | + </LinearLayout> | ||
| 39 | + | ||
| 40 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 41 | \ No newline at end of file |
| @@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="wrap_content" | ||
| 4 | + android:layout_height="wrap_content" | ||
| 5 | + android:padding="5dp"> | ||
| 6 | + | ||
| 7 | + <TextView | ||
| 8 | + android:id="@+id/mychat_time" | ||
| 9 | + android:layout_width="wrap_content" | ||
| 10 | + android:layout_height="wrap_content" | ||
| 11 | + android:layout_alignParentTop="true" | ||
| 12 | + android:layout_centerHorizontal="true" | ||
| 13 | + android:textColor="@color/light_gray_6" | ||
| 14 | + android:textSize="10sp" | ||
| 15 | + android:visibility="gone" /> | ||
| 16 | + | ||
| 17 | + <ImageView | ||
| 18 | + android:id="@+id/tb_my_user_icon" | ||
| 19 | + android:layout_width="50dp" | ||
| 20 | + android:layout_height="50dp" | ||
| 21 | + android:layout_alignParentRight="true" | ||
| 22 | + android:layout_below="@id/mychat_time" /> | ||
| 23 | + | ||
| 24 | + <LinearLayout | ||
| 25 | + android:layout_width="wrap_content" | ||
| 26 | + android:layout_height="wrap_content" | ||
| 27 | + android:layout_below="@id/mychat_time" | ||
| 28 | + android:layout_toLeftOf="@+id/tb_my_user_icon" | ||
| 29 | + android:orientation="horizontal"> | ||
| 30 | + | ||
| 31 | + <com.shunzhi.mychartlibrary.widget.GifTextView | ||
| 32 | + android:id="@+id/mycontent" | ||
| 33 | + android:layout_width="wrap_content" | ||
| 34 | + android:layout_height="wrap_content" | ||
| 35 | + android:layout_margin="5dp" | ||
| 36 | + android:background="@drawable/chatto_bg_focused" | ||
| 37 | + android:textColor="@color/white" | ||
| 38 | + android:textSize="16sp" /> | ||
| 39 | + </LinearLayout> | ||
| 40 | + | ||
| 41 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 42 | \ No newline at end of file |
| @@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
| 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="match_parent" | ||
| 5 | + android:orientation="vertical" > | ||
| 6 | + <TextView | ||
| 7 | + android:id="@+id/pull_text" | ||
| 8 | + android:layout_width="match_parent" | ||
| 9 | + android:layout_height="wrap_content" | ||
| 10 | + android:text="pull to refresh!" | ||
| 11 | + /> | ||
| 12 | + <com.maxi.chatdemo.widget.pulltorefresh.PullToRefreshRecyclerView | ||
| 13 | + android:id="@+id/pull_list" | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="match_parent" | ||
| 16 | + android:background="#ffffff" | ||
| 17 | + /> | ||
| 18 | + | ||
| 19 | +</LinearLayout> | ||
| 0 | \ No newline at end of file | 20 | \ No newline at end of file |
| @@ -0,0 +1,71 @@ | @@ -0,0 +1,71 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="wrap_content" | ||
| 4 | + android:layout_height="wrap_content" | ||
| 5 | + android:padding="5dp"> | ||
| 6 | + | ||
| 7 | + <TextView | ||
| 8 | + android:id="@+id/chat_time" | ||
| 9 | + android:layout_width="wrap_content" | ||
| 10 | + android:layout_height="wrap_content" | ||
| 11 | + android:layout_alignParentTop="true" | ||
| 12 | + android:layout_centerHorizontal="true" | ||
| 13 | + android:textColor="@color/light_gray_6" | ||
| 14 | + android:textSize="10sp" | ||
| 15 | + android:visibility="gone" /> | ||
| 16 | + | ||
| 17 | + <ImageView | ||
| 18 | + android:id="@+id/tb_other_user_icon" | ||
| 19 | + android:layout_width="50dp" | ||
| 20 | + android:layout_height="50dp" | ||
| 21 | + android:layout_alignParentLeft="true" | ||
| 22 | + android:layout_below="@id/chat_time" /> | ||
| 23 | + | ||
| 24 | + <LinearLayout | ||
| 25 | + android:layout_width="wrap_content" | ||
| 26 | + android:layout_height="wrap_content" | ||
| 27 | + android:layout_below="@id/chat_time" | ||
| 28 | + android:layout_toRightOf="@+id/tb_other_user_icon" | ||
| 29 | + android:orientation="horizontal"> | ||
| 30 | + | ||
| 31 | + <LinearLayout | ||
| 32 | + android:id="@+id/voice_group" | ||
| 33 | + android:layout_width="wrap_content" | ||
| 34 | + android:layout_height="wrap_content" | ||
| 35 | + android:layout_margin="5dp" | ||
| 36 | + android:orientation="horizontal" | ||
| 37 | + android:visibility="gone"> | ||
| 38 | + | ||
| 39 | + <FrameLayout | ||
| 40 | + android:id="@+id/voice_receiver_image" | ||
| 41 | + android:layout_width="wrap_content" | ||
| 42 | + android:layout_height="wrap_content" | ||
| 43 | + android:layout_gravity="center" | ||
| 44 | + android:background="@drawable/chatfrom_bg_focused"> | ||
| 45 | + | ||
| 46 | + <View | ||
| 47 | + android:id="@+id/id_receiver_recorder_anim" | ||
| 48 | + android:layout_width="15dp" | ||
| 49 | + android:layout_height="15dp" | ||
| 50 | + android:layout_gravity="center_vertical|left" | ||
| 51 | + android:background="@mipmap/receiver_voice_node_playing003" /> | ||
| 52 | + | ||
| 53 | + <View | ||
| 54 | + android:id="@+id/receiver_voice_unread" | ||
| 55 | + android:layout_width="10dp" | ||
| 56 | + android:layout_height="10dp" | ||
| 57 | + android:layout_gravity="center_vertical|right" | ||
| 58 | + android:background="@mipmap/msg_chat_voice_unread" /> | ||
| 59 | + </FrameLayout> | ||
| 60 | + | ||
| 61 | + <TextView | ||
| 62 | + android:id="@+id/voice_time" | ||
| 63 | + android:layout_width="wrap_content" | ||
| 64 | + android:layout_height="wrap_content" | ||
| 65 | + android:layout_gravity="center_vertical" | ||
| 66 | + android:textColor="@color/middle_gray_1" /> | ||
| 67 | + </LinearLayout> | ||
| 68 | + | ||
| 69 | + </LinearLayout> | ||
| 70 | + | ||
| 71 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 72 | \ No newline at end of file |
| @@ -0,0 +1,70 @@ | @@ -0,0 +1,70 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="wrap_content" | ||
| 4 | + android:layout_height="wrap_content" | ||
| 5 | + android:padding="5dp"> | ||
| 6 | + | ||
| 7 | + <TextView | ||
| 8 | + android:id="@+id/mychat_time" | ||
| 9 | + android:layout_width="wrap_content" | ||
| 10 | + android:layout_height="wrap_content" | ||
| 11 | + android:layout_alignParentTop="true" | ||
| 12 | + android:layout_centerHorizontal="true" | ||
| 13 | + android:textColor="@color/light_gray_6" | ||
| 14 | + android:textSize="10sp" | ||
| 15 | + android:visibility="gone" /> | ||
| 16 | + | ||
| 17 | + <ImageView | ||
| 18 | + android:id="@+id/tb_my_user_icon" | ||
| 19 | + android:layout_width="50dp" | ||
| 20 | + android:layout_height="50dp" | ||
| 21 | + android:layout_alignParentRight="true" | ||
| 22 | + android:layout_below="@id/mychat_time" /> | ||
| 23 | + | ||
| 24 | + <LinearLayout | ||
| 25 | + android:layout_width="wrap_content" | ||
| 26 | + android:layout_height="wrap_content" | ||
| 27 | + android:layout_below="@id/mychat_time" | ||
| 28 | + android:layout_toLeftOf="@+id/tb_my_user_icon" | ||
| 29 | + android:orientation="horizontal"> | ||
| 30 | + | ||
| 31 | + <ImageView | ||
| 32 | + android:id="@+id/mysend_fail_img" | ||
| 33 | + android:layout_width="25dp" | ||
| 34 | + android:layout_height="25dp" | ||
| 35 | + android:layout_gravity="center_vertical" | ||
| 36 | + android:background="@mipmap/msg_state_fail_resend_pressed" /> | ||
| 37 | + | ||
| 38 | + <LinearLayout | ||
| 39 | + android:id="@+id/voice_group" | ||
| 40 | + android:layout_width="wrap_content" | ||
| 41 | + android:layout_height="wrap_content" | ||
| 42 | + android:layout_margin="5dp" | ||
| 43 | + android:orientation="horizontal" | ||
| 44 | + android:visibility="gone"> | ||
| 45 | + | ||
| 46 | + <TextView | ||
| 47 | + android:id="@+id/voice_time" | ||
| 48 | + android:layout_width="wrap_content" | ||
| 49 | + android:layout_height="wrap_content" | ||
| 50 | + android:layout_gravity="center_vertical" | ||
| 51 | + android:textColor="@color/middle_gray_1" /> | ||
| 52 | + | ||
| 53 | + <FrameLayout | ||
| 54 | + android:id="@+id/voice_image" | ||
| 55 | + android:layout_width="wrap_content" | ||
| 56 | + android:layout_height="wrap_content" | ||
| 57 | + android:layout_gravity="center" | ||
| 58 | + android:background="@drawable/chatto_bg_focused"> | ||
| 59 | + | ||
| 60 | + <View | ||
| 61 | + android:id="@+id/id_recorder_anim" | ||
| 62 | + android:layout_width="15dp" | ||
| 63 | + android:layout_height="15dp" | ||
| 64 | + android:layout_gravity="center_vertical|right" | ||
| 65 | + android:background="@mipmap/adj" /> | ||
| 66 | + </FrameLayout> | ||
| 67 | + </LinearLayout> | ||
| 68 | + </LinearLayout> | ||
| 69 | + | ||
| 70 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 71 | \ No newline at end of file |
4.06 KB
3.79 KB
7.89 KB
2.24 KB
1.74 KB
1.81 KB
1.57 KB
1.42 KB
7.99 KB
7.99 KB
1.81 KB
1.59 KB
1.87 KB
3.02 KB
1.95 KB
2.25 KB
2.43 KB
3.96 KB
2.64 KB
3.34 KB
4.84 KB
1.78 KB
1.81 KB
7.24 KB
4.39 KB
2.13 KB
1.43 KB
1.21 KB
1.68 KB
1.8 KB
1.14 KB
2.54 KB
1.39 KB
1.85 KB
1.28 KB
1.98 KB
3.19 KB
3.9 KB
4.92 KB
3.37 KB
app/src/main/res/mipmap-hdpi/ic_launcher.png
1.72 KB
3.01 KB
828 Bytes
414 Bytes
3.01 KB
2.06 KB
142 KB
app/src/main/res/mipmap-xhdpi/ic_launcher.png
1.18 KB
592 Bytes
82 Bytes
162 Bytes
356 Bytes
591 Bytes
3.32 KB
17.4 KB
18.8 KB
20.2 KB
6.92 KB
14.3 KB
14.4 KB