|
@@ -27,6 +27,7 @@ import android.widget.ArrayAdapter;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.Glide;
|
|
|
import com.kfzs.cfyl.share_library.util.CallBackAPI;
|
|
import com.kfzs.cfyl.share_library.util.CallBackAPI;
|
|
|
import com.kfzs.duanduan.utils.ApkUtils;
|
|
import com.kfzs.duanduan.utils.ApkUtils;
|
|
@@ -35,6 +36,7 @@ import com.sheep.gamegroup.absBase.AbsObserver;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.CreditCard;
|
|
import com.sheep.gamegroup.model.entity.CreditCard;
|
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
|
|
|
+import com.sheep.gamegroup.model.entity.DiscoveryVideo;
|
|
|
import com.sheep.gamegroup.model.entity.LoginEntity;
|
|
import com.sheep.gamegroup.model.entity.LoginEntity;
|
|
|
import com.sheep.gamegroup.model.entity.LoginUser;
|
|
import com.sheep.gamegroup.model.entity.LoginUser;
|
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
@@ -735,6 +737,99 @@ public class TestUtil {
|
|
|
return BuildConfig.VERSION_CODE < 3004005;
|
|
return BuildConfig.VERSION_CODE < 3004005;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static void testArticleVideo(View itemView, List<DiscoveryVideo> videoList, DiscoveryVideo item) {
|
|
|
|
|
+ if(isTest()){
|
|
|
|
|
+ itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onLongClick(View view) {
|
|
|
|
|
+ Activity activity = SheepApp.getInstance().getCurrentActivity();
|
|
|
|
|
+ List<String> list = ListUtil.emptyList();
|
|
|
|
|
+ list.add("自动修复所有时长问题");
|
|
|
|
|
+ list.add("封面90");
|
|
|
|
|
+ list.add("封面270");
|
|
|
|
|
+ list.add("时长");
|
|
|
|
|
+ AlertDialog dialog = new AlertDialog.Builder(activity).setTitle("测试:选择要修改的数据")
|
|
|
|
|
+ .setAdapter(new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1, list), new DialogInterface.OnClickListener() {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(DialogInterface dialogInterface, int which) {
|
|
|
|
|
+ String chooseAction = list.get(which);
|
|
|
|
|
+ switch (chooseAction){
|
|
|
|
|
+ case "封面90":
|
|
|
|
|
+ resetArticleVideoCover(item, 90);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "封面270":
|
|
|
|
|
+ resetArticleVideoCover(item, 270);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "自动修复所有时长问题":
|
|
|
|
|
+ resetArticleVideoDuration(videoList);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "时长":
|
|
|
|
|
+ resetArticleVideoDuration(item);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }).create();
|
|
|
|
|
+ dialog.show();
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static void resetArticleVideoCover(DiscoveryVideo item, int rotate) {
|
|
|
|
|
+ item.setCover(item.getResource()+"?vframe/jpg/offset/0/rotate/"+rotate);
|
|
|
|
|
+ resetArticleVideo(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //自动修复所有视频的时长
|
|
|
|
|
+ private static void resetArticleVideoDuration(List<DiscoveryVideo> videoList) {
|
|
|
|
|
+ for (DiscoveryVideo video : videoList) {
|
|
|
|
|
+ if(video.getDuration() < 1 || video.getDuration() > 15)//时长小于1,大于15代表错误
|
|
|
|
|
+ resetArticleVideoDuration(video);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //自动修复单个视频的时长
|
|
|
|
|
+ private static void resetArticleVideoDuration(DiscoveryVideo item) {
|
|
|
|
|
+ OkHttpUtils.get().url(item.getResource()+"?avinfo")
|
|
|
|
|
+ .build().execute(new StringCallback() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(Call call, Exception e, int id) {
|
|
|
|
|
+ G.showToast(e);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onResponse(String response, int id) {
|
|
|
|
|
+ JSONObject result = JSON.parseObject(response);
|
|
|
|
|
+ JSONObject format = result.getJSONObject("format");
|
|
|
|
|
+ item.setDuration(Float.valueOf(format.getString("duration")).intValue());
|
|
|
|
|
+ item.setCover(item.getResource()+"?vframe/png/offset/0");
|
|
|
|
|
+ resetArticleVideo(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ private static void resetArticleVideo(DiscoveryVideo item){
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ jsonObject.put("id", item.getId());
|
|
|
|
|
+ jsonObject.put("duration", item.getDuration());
|
|
|
|
|
+ jsonObject.put("cover", item.getCover());
|
|
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().putVideo(jsonObject)
|
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* umen 分享
|
|
* umen 分享
|
|
|
*/
|
|
*/
|