Procházet zdrojové kódy

新手引导中非表情图片充满显示;
优化新手引导内容与展示

zengjiebin před 7 roky
rodič
revize
898250f161

+ 12 - 12
app/src/main/java/com/sheep/gamegroup/greendao/download/DaoMaster.java

@@ -21,24 +21,24 @@ public class DaoMaster extends AbstractDaoMaster {
 
     /** Creates underlying database table using DAOs. */
     public static void createAllTables(Database db, boolean ifNotExists) {
-        ProcessRecordDao.createTable(db, ifNotExists);
+        AcceptTaskRecordDao.createTable(db, ifNotExists);
         AppdownloadBeanDao.createTable(db, ifNotExists);
-        SdkLoginUserDao.createTable(db, ifNotExists);
+        DownLoadInfoDao.createTable(db, ifNotExists);
+        ProcessRecordDao.createTable(db, ifNotExists);
         ScreenShotRecordDao.createTable(db, ifNotExists);
-        AcceptTaskRecordDao.createTable(db, ifNotExists);
+        SdkLoginUserDao.createTable(db, ifNotExists);
         SearchRecordDao.createTable(db, ifNotExists);
-        DownLoadInfoDao.createTable(db, ifNotExists);
     }
 
     /** Drops underlying database table using DAOs. */
     public static void dropAllTables(Database db, boolean ifExists) {
-        ProcessRecordDao.dropTable(db, ifExists);
+        AcceptTaskRecordDao.dropTable(db, ifExists);
         AppdownloadBeanDao.dropTable(db, ifExists);
-        SdkLoginUserDao.dropTable(db, ifExists);
+        DownLoadInfoDao.dropTable(db, ifExists);
+        ProcessRecordDao.dropTable(db, ifExists);
         ScreenShotRecordDao.dropTable(db, ifExists);
-        AcceptTaskRecordDao.dropTable(db, ifExists);
+        SdkLoginUserDao.dropTable(db, ifExists);
         SearchRecordDao.dropTable(db, ifExists);
-        DownLoadInfoDao.dropTable(db, ifExists);
     }
 
     /**
@@ -57,13 +57,13 @@ public class DaoMaster extends AbstractDaoMaster {
 
     public DaoMaster(Database db) {
         super(db, SCHEMA_VERSION);
-        registerDaoClass(ProcessRecordDao.class);
+        registerDaoClass(AcceptTaskRecordDao.class);
         registerDaoClass(AppdownloadBeanDao.class);
-        registerDaoClass(SdkLoginUserDao.class);
+        registerDaoClass(DownLoadInfoDao.class);
+        registerDaoClass(ProcessRecordDao.class);
         registerDaoClass(ScreenShotRecordDao.class);
-        registerDaoClass(AcceptTaskRecordDao.class);
+        registerDaoClass(SdkLoginUserDao.class);
         registerDaoClass(SearchRecordDao.class);
-        registerDaoClass(DownLoadInfoDao.class);
     }
 
     public DaoSession newSession() {

+ 47 - 47
app/src/main/java/com/sheep/gamegroup/greendao/download/DaoSession.java

@@ -8,21 +8,21 @@ import org.greenrobot.greendao.database.Database;
 import org.greenrobot.greendao.identityscope.IdentityScopeType;
 import org.greenrobot.greendao.internal.DaoConfig;
 
-import com.sheep.gamegroup.greendao.download.ProcessRecord;
+import com.sheep.gamegroup.greendao.download.AcceptTaskRecord;
 import com.sheep.gamegroup.greendao.download.AppdownloadBean;
-import com.sheep.gamegroup.greendao.download.SdkLoginUser;
+import com.sheep.gamegroup.greendao.download.DownLoadInfo;
+import com.sheep.gamegroup.greendao.download.ProcessRecord;
 import com.sheep.gamegroup.greendao.download.ScreenShotRecord;
-import com.sheep.gamegroup.greendao.download.AcceptTaskRecord;
+import com.sheep.gamegroup.greendao.download.SdkLoginUser;
 import com.sheep.gamegroup.greendao.download.SearchRecord;
-import com.sheep.gamegroup.greendao.download.DownLoadInfo;
 
-import com.sheep.gamegroup.greendao.download.ProcessRecordDao;
+import com.sheep.gamegroup.greendao.download.AcceptTaskRecordDao;
 import com.sheep.gamegroup.greendao.download.AppdownloadBeanDao;
-import com.sheep.gamegroup.greendao.download.SdkLoginUserDao;
+import com.sheep.gamegroup.greendao.download.DownLoadInfoDao;
+import com.sheep.gamegroup.greendao.download.ProcessRecordDao;
 import com.sheep.gamegroup.greendao.download.ScreenShotRecordDao;
-import com.sheep.gamegroup.greendao.download.AcceptTaskRecordDao;
+import com.sheep.gamegroup.greendao.download.SdkLoginUserDao;
 import com.sheep.gamegroup.greendao.download.SearchRecordDao;
-import com.sheep.gamegroup.greendao.download.DownLoadInfoDao;
 
 // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
 
@@ -33,100 +33,100 @@ import com.sheep.gamegroup.greendao.download.DownLoadInfoDao;
  */
 public class DaoSession extends AbstractDaoSession {
 
-    private final DaoConfig processRecordDaoConfig;
+    private final DaoConfig acceptTaskRecordDaoConfig;
     private final DaoConfig appdownloadBeanDaoConfig;
-    private final DaoConfig sdkLoginUserDaoConfig;
+    private final DaoConfig downLoadInfoDaoConfig;
+    private final DaoConfig processRecordDaoConfig;
     private final DaoConfig screenShotRecordDaoConfig;
-    private final DaoConfig acceptTaskRecordDaoConfig;
+    private final DaoConfig sdkLoginUserDaoConfig;
     private final DaoConfig searchRecordDaoConfig;
-    private final DaoConfig downLoadInfoDaoConfig;
 
-    private final ProcessRecordDao processRecordDao;
+    private final AcceptTaskRecordDao acceptTaskRecordDao;
     private final AppdownloadBeanDao appdownloadBeanDao;
-    private final SdkLoginUserDao sdkLoginUserDao;
+    private final DownLoadInfoDao downLoadInfoDao;
+    private final ProcessRecordDao processRecordDao;
     private final ScreenShotRecordDao screenShotRecordDao;
-    private final AcceptTaskRecordDao acceptTaskRecordDao;
+    private final SdkLoginUserDao sdkLoginUserDao;
     private final SearchRecordDao searchRecordDao;
-    private final DownLoadInfoDao downLoadInfoDao;
 
     public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
             daoConfigMap) {
         super(db);
 
-        processRecordDaoConfig = daoConfigMap.get(ProcessRecordDao.class).clone();
-        processRecordDaoConfig.initIdentityScope(type);
+        acceptTaskRecordDaoConfig = daoConfigMap.get(AcceptTaskRecordDao.class).clone();
+        acceptTaskRecordDaoConfig.initIdentityScope(type);
 
         appdownloadBeanDaoConfig = daoConfigMap.get(AppdownloadBeanDao.class).clone();
         appdownloadBeanDaoConfig.initIdentityScope(type);
 
-        sdkLoginUserDaoConfig = daoConfigMap.get(SdkLoginUserDao.class).clone();
-        sdkLoginUserDaoConfig.initIdentityScope(type);
+        downLoadInfoDaoConfig = daoConfigMap.get(DownLoadInfoDao.class).clone();
+        downLoadInfoDaoConfig.initIdentityScope(type);
+
+        processRecordDaoConfig = daoConfigMap.get(ProcessRecordDao.class).clone();
+        processRecordDaoConfig.initIdentityScope(type);
 
         screenShotRecordDaoConfig = daoConfigMap.get(ScreenShotRecordDao.class).clone();
         screenShotRecordDaoConfig.initIdentityScope(type);
 
-        acceptTaskRecordDaoConfig = daoConfigMap.get(AcceptTaskRecordDao.class).clone();
-        acceptTaskRecordDaoConfig.initIdentityScope(type);
+        sdkLoginUserDaoConfig = daoConfigMap.get(SdkLoginUserDao.class).clone();
+        sdkLoginUserDaoConfig.initIdentityScope(type);
 
         searchRecordDaoConfig = daoConfigMap.get(SearchRecordDao.class).clone();
         searchRecordDaoConfig.initIdentityScope(type);
 
-        downLoadInfoDaoConfig = daoConfigMap.get(DownLoadInfoDao.class).clone();
-        downLoadInfoDaoConfig.initIdentityScope(type);
-
-        processRecordDao = new ProcessRecordDao(processRecordDaoConfig, this);
+        acceptTaskRecordDao = new AcceptTaskRecordDao(acceptTaskRecordDaoConfig, this);
         appdownloadBeanDao = new AppdownloadBeanDao(appdownloadBeanDaoConfig, this);
-        sdkLoginUserDao = new SdkLoginUserDao(sdkLoginUserDaoConfig, this);
+        downLoadInfoDao = new DownLoadInfoDao(downLoadInfoDaoConfig, this);
+        processRecordDao = new ProcessRecordDao(processRecordDaoConfig, this);
         screenShotRecordDao = new ScreenShotRecordDao(screenShotRecordDaoConfig, this);
-        acceptTaskRecordDao = new AcceptTaskRecordDao(acceptTaskRecordDaoConfig, this);
+        sdkLoginUserDao = new SdkLoginUserDao(sdkLoginUserDaoConfig, this);
         searchRecordDao = new SearchRecordDao(searchRecordDaoConfig, this);
-        downLoadInfoDao = new DownLoadInfoDao(downLoadInfoDaoConfig, this);
 
-        registerDao(ProcessRecord.class, processRecordDao);
+        registerDao(AcceptTaskRecord.class, acceptTaskRecordDao);
         registerDao(AppdownloadBean.class, appdownloadBeanDao);
-        registerDao(SdkLoginUser.class, sdkLoginUserDao);
+        registerDao(DownLoadInfo.class, downLoadInfoDao);
+        registerDao(ProcessRecord.class, processRecordDao);
         registerDao(ScreenShotRecord.class, screenShotRecordDao);
-        registerDao(AcceptTaskRecord.class, acceptTaskRecordDao);
+        registerDao(SdkLoginUser.class, sdkLoginUserDao);
         registerDao(SearchRecord.class, searchRecordDao);
-        registerDao(DownLoadInfo.class, downLoadInfoDao);
     }
     
     public void clear() {
-        processRecordDaoConfig.clearIdentityScope();
+        acceptTaskRecordDaoConfig.clearIdentityScope();
         appdownloadBeanDaoConfig.clearIdentityScope();
-        sdkLoginUserDaoConfig.clearIdentityScope();
+        downLoadInfoDaoConfig.clearIdentityScope();
+        processRecordDaoConfig.clearIdentityScope();
         screenShotRecordDaoConfig.clearIdentityScope();
-        acceptTaskRecordDaoConfig.clearIdentityScope();
+        sdkLoginUserDaoConfig.clearIdentityScope();
         searchRecordDaoConfig.clearIdentityScope();
-        downLoadInfoDaoConfig.clearIdentityScope();
     }
 
-    public ProcessRecordDao getProcessRecordDao() {
-        return processRecordDao;
+    public AcceptTaskRecordDao getAcceptTaskRecordDao() {
+        return acceptTaskRecordDao;
     }
 
     public AppdownloadBeanDao getAppdownloadBeanDao() {
         return appdownloadBeanDao;
     }
 
-    public SdkLoginUserDao getSdkLoginUserDao() {
-        return sdkLoginUserDao;
+    public DownLoadInfoDao getDownLoadInfoDao() {
+        return downLoadInfoDao;
+    }
+
+    public ProcessRecordDao getProcessRecordDao() {
+        return processRecordDao;
     }
 
     public ScreenShotRecordDao getScreenShotRecordDao() {
         return screenShotRecordDao;
     }
 
-    public AcceptTaskRecordDao getAcceptTaskRecordDao() {
-        return acceptTaskRecordDao;
+    public SdkLoginUserDao getSdkLoginUserDao() {
+        return sdkLoginUserDao;
     }
 
     public SearchRecordDao getSearchRecordDao() {
         return searchRecordDao;
     }
 
-    public DownLoadInfoDao getDownLoadInfoDao() {
-        return downLoadInfoDao;
-    }
-
 }

+ 14 - 7
app/src/main/java/com/sheep/gamegroup/util/DetailImageGetter.java

@@ -35,6 +35,8 @@ public class DetailImageGetter implements Html.ImageGetter {
         textSize = G.getRealPix(60);
     }
 
+    //非表情图片尝试充满TextView显示
+    public static final boolean IMG_FULL = true;
     @Override
     public Drawable getDrawable(final String source) {
         Resources resources = SheepApp.getInstance().getResources();
@@ -50,15 +52,20 @@ public class DetailImageGetter implements Html.ImageGetter {
                 if(drawable != null){
                     int minimumWidth = drawable.getMinimumWidth();
                     int minimumHeight = drawable.getMinimumHeight();
-                    int imgWidth = G.getRealPix(minimumWidth);
-                    int imgHeight = G.getRealPix(minimumHeight);
-                    int imgLeft = 0;
-                    if(imgWidth > maxWidth && maxWidth > 0){
-                        imgHeight = (int) (maxWidth * imgHeight * 1.0f / imgWidth);
+                    int imgWidth, imgHeight, imgLeft = 0;
+                    if(IMG_FULL){
                         imgWidth = maxWidth;
+                        imgHeight = minimumHeight * maxWidth / minimumWidth;
                     } else {
-                        imgLeft = (maxWidth - imgWidth) / 2;
-                        imgWidth += imgLeft;
+                        imgWidth = G.getRealPix(minimumWidth);
+                        imgHeight = G.getRealPix(minimumHeight);
+                        if (imgWidth > maxWidth && maxWidth > 0) {
+                            imgHeight = (int) (maxWidth * imgHeight * 1.0f / imgWidth);
+                            imgWidth = maxWidth;
+                        } else {
+                            imgLeft = (maxWidth - imgWidth) / 2;
+                            imgWidth += imgLeft;
+                        }
                     }
                     drawable.setBounds(imgLeft, 0, imgWidth, imgHeight);
                     return drawable;

+ 13 - 7
app/src/main/java/com/sheep/gamegroup/util/DetailTagHandler.java

@@ -34,16 +34,22 @@ public class DetailTagHandler implements Html.TagHandler {
             // 获取图片地址
             ImageSpan[] images = output.getSpans(len - 1, len, ImageSpan.class);
             String imgURL = images[0].getSource();
-            // 记录所有图片地址
-            strings.add(imgURL);
-            // 记录是第几张图片
-            int position = strings.size() - 1;
-            // 使图片可点击并监听点击事件
-            output.setSpan(new ClickableImage(position), len - 1, len,
-                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+            if(imgURL != null && (imgURL.startsWith("http://") || imgURL.startsWith("https://"))) {
+                // 记录所有图片地址
+                strings.add(imgURL);
+                // 记录是第几张图片
+                int position = strings.size() - 1;
+                // 使图片可点击并监听点击事件
+                output.setSpan(new ClickableImage(position), len - 1, len,
+                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+            }
         }
     }
 
+    public void clear() {
+        strings.clear();
+    }
+
     private class ClickableImage extends ClickableSpan {
         private int position;
 

+ 28 - 0
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -978,6 +978,20 @@ public class ViewUtil {
             textView.setMovementMethod(LinkMovementMethod.getInstance());
         }
     }
+    public static void setH5ImgText(TextView textView, String content, int maxWidth, Html.TagHandler tagHandler) {
+        if (textView != null) {
+            if (TextUtils.isEmpty(content)) {
+                textView.setText("");
+                return;
+            }
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+                textView.setText(Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY, new DetailImageGetter(textView, content, maxWidth), tagHandler));
+            } else {
+                textView.setText(Html.fromHtml(content, new DetailImageGetter(textView, content, maxWidth), tagHandler));
+            }
+            textView.setMovementMethod(LinkMovementMethod.getInstance());
+        }
+    }
 
     public static void loadDataWithBaseURL(com.tencent.smtt.sdk.WebView webView, String content) {
         webView.loadDataWithBaseURL(null,
@@ -1601,6 +1615,20 @@ public class ViewUtil {
                 break;
         }
     }
+    public static void setText(TextView textView, IContentTypeContainer<Integer, String> contentTypeContainer, int maxWidth, Html.TagHandler tagHandler) {
+        switch (contentTypeContainer.getContentType()) {
+            case StringUtils.CONTENT_TYPE_FONT:
+                setText(textView, contentTypeContainer.getContentResult());
+                break;
+            case StringUtils.CONTENT_TYPE_H5:
+//                setH5Text(textView, contentTypeContainer.getContentResult());
+                setH5ImgText(textView, contentTypeContainer.getContentResult(), maxWidth, tagHandler);
+                break;
+            case StringUtils.CONTENT_TYPE_EXP:
+                setH5ImgText(textView, contentTypeContainer.getContentResult(), maxWidth, tagHandler);
+                break;
+        }
+    }
 
     public static void setText(TextView textView, int integer) {
         if (textView != null) {

+ 8 - 5
app/src/main/java/com/sheep/gamegroup/view/adapter/AdpNoviceGuidance.java

@@ -10,6 +10,7 @@ import android.widget.VideoView;
 import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
 import com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder;
 import com.sheep.gamegroup.model.entity.NoviceGuidance;
+import com.sheep.gamegroup.util.DetailTagHandler;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.ViewUtil;
@@ -27,6 +28,7 @@ public class AdpNoviceGuidance extends RecyclerViewAdapter<NoviceGuidance> {
         super(context, R.layout.item_novice_guidance, dataList);
     }
 
+    private DetailTagHandler tagHandler = new DetailTagHandler();
     @Override
     public void convert(ViewHolder viewHolder, final NoviceGuidance item, int position) {
         TextView item_novice_guidance_title = viewHolder.itemView.findViewById(R.id.item_novice_guidance_title);
@@ -49,7 +51,7 @@ public class AdpNoviceGuidance extends RecyclerViewAdapter<NoviceGuidance> {
         ViewUtil.setImage(item_novice_guidance_video_image, item.getPre_url());
         ViewUtil.setImage(item_novice_guidance_image, item.getImage_url());
         ViewUtil.setText(item_novice_guidance_title, item.getTitle());
-        ViewUtil.setText(item_novice_guidance_content, item, G.WIDTH - G.getRealPix(32));
+        ViewUtil.setText(item_novice_guidance_content, item, G.WIDTH - G.getRealPix(32), tagHandler);
 //        ViewUtil.setVideoAndFull(item_novice_guidance_video, item_novice_guidance_video_image, item_novice_guidance_video_control, item.getVideo_url());
         item_novice_guidance_video_control.setOnClickListener(new View.OnClickListener() {
             @Override
@@ -59,12 +61,13 @@ public class AdpNoviceGuidance extends RecyclerViewAdapter<NoviceGuidance> {
         });
 //        if(!viewHolderList.contains(viewHolder) && !TextUtils.isEmpty(item.getVideo_url()))
 //            viewHolderList.add(viewHolder);
-//    }
+    }
 //
 //    private List<ViewHolder> viewHolderList = ListUtil.emptyList();
-//    public void beforeNotifyDataSetChanged(){
+    public void beforeNotifyDataSetChanged(){
+        tagHandler.clear();
 //        viewHolderList.clear();
-//    }
+    }
 //    public void onPause() {
 //        for (ViewHolder viewHolder : viewHolderList) {
 //            VideoView item_novice_guidance_video = viewHolder.itemView.findViewById(R.id.item_novice_guidance_video);
@@ -80,5 +83,5 @@ public class AdpNoviceGuidance extends RecyclerViewAdapter<NoviceGuidance> {
 //                item_novice_guidance_video.stopPlayback();
 //        }
 //        viewHolderList.clear();
-    }
+//    }
 }

+ 8 - 23
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtUserNoviceGuidance.java

@@ -6,14 +6,11 @@ import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.NoviceGuidance;
 import com.sheep.gamegroup.view.adapter.AdpNoviceGuidance;
-import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
 import org.afinal.simplecache.ApiKey;
 
-import java.util.List;
-
 import io.reactivex.Observable;
 
 /**
@@ -46,32 +43,20 @@ public class FgtUserNoviceGuidance extends BaseListFragment2<NoviceGuidance> {
         return apiService.getNoviceGuidance();
     }
 
-    private NoviceGuidance noviceGuidance;
-    @Override
-    protected void loadList(List<NoviceGuidance> addList) {
-        if(noviceGuidance == null){
-            noviceGuidance = new NoviceGuidance();
-            noviceGuidance.setContent(getString(R.string.new_nav_tips_title));
-        }
-        list.clear();
-        list.add(noviceGuidance);
-        super.loadList(addList);
-    }
-
     @Override
     protected Class<NoviceGuidance> getTClass() {
         return NoviceGuidance.class;
     }
-//
-//    @Override
-//    public void notifyDataSetChanged() {
-//        if(adapter != null){
-//            adapter.beforeNotifyDataSetChanged();
-//        }
-//        super.notifyDataSetChanged();
+
+    @Override
+    public void notifyDataSetChanged() {
+        if(adapter != null){
+            adapter.beforeNotifyDataSetChanged();
+        }
+        super.notifyDataSetChanged();
 //        if(!list.isEmpty())
 //            view_list.setPullRefreshEnabled(false);
-//    }
+    }
 //
 //    @Override
 //    public void onPause() {

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
app/src/main/res/values/strings.xml