Warkop v5.73.0版本的 MD5 值为:a4330ec2d6f5e146f59fc7622f3cdb45
以下内容为反编译后的 ElementGenerator.java 源代码,内容仅作参考
package com.inappstory.sdk.stories.ui.widgets.readerscreen.generated;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.graphics.drawable.GradientDrawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.appcompat.widget.AppCompatTextView;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.inappstory.sdk.AppearanceManager;
import com.inappstory.sdk.InAppStoryService;
import com.inappstory.sdk.imageloader.ImageLoader;
import com.inappstory.sdk.network.JsonParser;
import com.inappstory.sdk.stories.api.models.StoryLink;
import com.inappstory.sdk.stories.api.models.StoryLinkObject;
import com.inappstory.sdk.stories.api.models.slidestructure.Background;
import com.inappstory.sdk.stories.api.models.slidestructure.Border;
import com.inappstory.sdk.stories.api.models.slidestructure.Element;
import com.inappstory.sdk.stories.api.models.slidestructure.Geometry;
import com.inappstory.sdk.stories.api.models.slidestructure.Source;
import com.inappstory.sdk.stories.api.models.slidestructure.Thumbnail;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
public class ElementGenerator {
static final String PROD_PRE_PATH = "https://cs2.kiozk.ru/file/";
static final String TEST_PRE_PATH = "https://cs.test.inappstory.com/np/file/";
public static final String TEXT_ALIGN_CENTER = "center";
public static final String TEXT_ALIGN_JUSTIFY = "justify";
public static final String TEXT_ALIGN_LEFT = "left";
public static final String TEXT_ALIGN_RIGHT = "right";
public static final String TYPE_IMAGE = "image";
public static final String TYPE_LINK = "link";
public static final String TYPE_TEXT = "text";
public static final String TYPE_TEXT_LINK = "text-link";
public static final String TYPE_VIDEO = "video";
public static String prePath = "https://cs.test.inappstory.com/np/file/";
public static class a implements View.OnClickListener {
final Element f31883c;
final SimpleViewCallback f31884d;
a(Element element, SimpleViewCallback simpleViewCallback) {
this.f31883c = element;
this.f31884d = simpleViewCallback;
}
@Override
public void onClick(View view) {
Element element = this.f31883c;
try {
this.f31884d.doAction(JsonParser.getJson(new StoryLinkObject(ElementGenerator.TYPE_LINK, new StoryLink(element.linkType, element.linkTarget))));
} catch (Exception e15) {
e15.printStackTrace();
}
}
}
public static GeneratedView generate(Element element, Context context, int i15, int i16) {
String str = element.type;
str.hashCode();
char c15 = 65535;
switch (str.hashCode()) {
case -1083981670:
if (str.equals(TYPE_TEXT_LINK)) {
c15 = 0;
break;
}
break;
case 3321850:
if (str.equals(TYPE_LINK)) {
c15 = 1;
break;
}
break;
case 3556653:
if (str.equals("text")) {
c15 = 2;
break;
}
break;
case 100313435:
if (str.equals(TYPE_IMAGE)) {
c15 = 3;
break;
}
break;
case 112202875:
if (str.equals("video")) {
c15 = 4;
break;
}
break;
}
switch (c15) {
case 0:
case 1:
return new GeneratedView(element.type, generateLink(element, context, i15, i16));
case 2:
return new GeneratedView(element.type, generateText(element, context, i15, i16));
case 3:
return new GeneratedView(element.type, generateImage(element, context, i15, i16));
case 4:
return new GeneratedView(element.type, generateVideo(element, context, i15, i16));
default:
return null;
}
}
static GeneratedImageView generateImage(Element element, Context context, int i15, int i16) {
RelativeLayout.LayoutParams layoutParams;
GeneratedImageView generatedImageView = new GeneratedImageView(context);
generatedImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
if (element.geometry.expand) {
layoutParams = new RelativeLayout.LayoutParams(-1, -1);
} else {
float f15 = i16;
Geometry geometry = element.geometry;
float f16 = i15;
layoutParams = new RelativeLayout.LayoutParams((int) ((geometry.width / 100.0f) * f15), (int) ((geometry.height / 100.0f) * f16));
Geometry geometry2 = element.geometry;
layoutParams.setMargins((int) ((geometry2.f31568x / 100.0f) * f15), (int) ((geometry2.f31569y / 100.0f) * f16), 0, 0);
}
generatedImageView.setLayoutParams(layoutParams);
Float f17 = element.opacity;
if (f17 != null) {
generatedImageView.setAlpha(f17.floatValue());
}
return generatedImageView;
}
static AppCompatTextView generateLink(Element element, Context context, int i15, int i16) {
RelativeLayout.LayoutParams layoutParams;
GeneratedTextView generatedTextView = new GeneratedTextView(context);
int i17 = 0;
generatedTextView.setTextColor(ColorParser.getColor(element.color, false));
generatedTextView.setTextSize(0, element.textSize * GeneratedViewSizes.getEMInPx());
CharSequence charSequence = element.content;
if (charSequence != null) {
generatedTextView.setText(charSequence);
}
char c15 = 65535;
if (element.geometry.expand) {
layoutParams = new RelativeLayout.LayoutParams(-1, -1);
} else {
float f15 = i16;
layoutParams = new RelativeLayout.LayoutParams((int) ((element.geometry.width / 100.0f) * f15), -2);
Geometry geometry = element.geometry;
layoutParams.setMargins((int) ((geometry.f31568x / 100.0f) * f15), (int) ((geometry.f31569y / 100.0f) * i15), 0, 0);
}
float f16 = i16;
int i18 = (int) ((element.padding * f16) / 20.0f);
generatedTextView.setPadding(i18, i18, i18, i18);
if (element.border != null || element.background != null) {
GradientDrawable gradientDrawable = new GradientDrawable();
Border border = element.border;
if (border != null) {
gradientDrawable.setCornerRadius((border.radius * f16) / 20.0f);
Border border2 = element.border;
float f17 = border2.width;
if (f17 > BitmapDescriptorFactory.HUE_RED) {
gradientDrawable.setStroke((int) ((f16 * f17) / 20.0f), ColorParser.getColor(border2.color, false));
}
}
Background background = element.background;
if (background != null) {
gradientDrawable.setColor(ColorParser.getColor(background.color, false));
}
generatedTextView.setBackground(gradientDrawable);
}
generatedTextView.setTextAlignment(1);
String str = element.align;
str.hashCode();
switch (str.hashCode()) {
case -1364013995:
if (str.equals(TEXT_ALIGN_CENTER)) {
c15 = 0;
break;
}
break;
case -1249482096:
if (str.equals(TEXT_ALIGN_JUSTIFY)) {
c15 = 1;
break;
}
break;
case 3317767:
if (str.equals(TEXT_ALIGN_LEFT)) {
c15 = 2;
break;
}
break;
case 108511772:
if (str.equals(TEXT_ALIGN_RIGHT)) {
c15 = 3;
break;
}
break;
}
switch (c15) {
case 0:
generatedTextView.setGravity(17);
break;
case 1:
case 2:
generatedTextView.setGravity(19);
break;
case 3:
generatedTextView.setGravity(21);
break;
}
generatedTextView.setLayoutParams(layoutParams);
Typeface font = AppearanceManager.getCommonInstance().getFont(element.secondaryFont, element.bold, element.italic);
boolean z15 = element.bold;
if (element.italic) {
i17 = 2;
}
if (font == null) {
font = generatedTextView.getTypeface();
}
generatedTextView.setTypeface(font, (z15 ? 1 : 0) + i17);
return generatedTextView;
}
static AppCompatTextView generateText(Element element, Context context, int i15, int i16) {
RelativeLayout.LayoutParams layoutParams;
GeneratedTextView generatedTextView = new GeneratedTextView(context);
int i17 = 0;
generatedTextView.setTextColor(ColorParser.getColor(element.color, false));
generatedTextView.setTextSize(0, element.textSize * GeneratedViewSizes.getEMInPx());
CharSequence charSequence = element.content;
if (charSequence != null) {
generatedTextView.setText(charSequence);
}
char c15 = 65535;
if (element.geometry.expand) {
layoutParams = new RelativeLayout.LayoutParams(-1, -1);
} else {
float f15 = i16;
layoutParams = new RelativeLayout.LayoutParams((int) ((element.geometry.width / 100.0f) * f15), -2);
Geometry geometry = element.geometry;
layoutParams.setMargins((int) ((geometry.f31568x / 100.0f) * f15), (int) ((geometry.f31569y / 100.0f) * i15), 0, 0);
}
float f16 = i16;
int i18 = (int) ((element.padding * f16) / 20.0f);
generatedTextView.setPadding(i18, i18, i18, i18);
if (element.border != null || element.background != null) {
GradientDrawable gradientDrawable = new GradientDrawable();
Border border = element.border;
if (border != null) {
gradientDrawable.setCornerRadius((border.radius * f16) / 20.0f);
Border border2 = element.border;
float f17 = border2.width;
if (f17 > BitmapDescriptorFactory.HUE_RED) {
gradientDrawable.setStroke((int) ((f16 * f17) / 20.0f), ColorParser.getColor(border2.color, false));
}
}
Background background = element.background;
if (background != null) {
gradientDrawable.setColor(ColorParser.getColor(background.color, false));
}
generatedTextView.setBackground(gradientDrawable);
}
generatedTextView.setTextAlignment(1);
String str = element.align;
str.hashCode();
switch (str.hashCode()) {
case -1364013995:
if (str.equals(TEXT_ALIGN_CENTER)) {
c15 = 0;
break;
}
break;
case -1249482096:
if (str.equals(TEXT_ALIGN_JUSTIFY)) {
c15 = 1;
break;
}
break;
case 3317767:
if (str.equals(TEXT_ALIGN_LEFT)) {
c15 = 2;
break;
}
break;
case 108511772:
if (str.equals(TEXT_ALIGN_RIGHT)) {
c15 = 3;
break;
}
break;
}
switch (c15) {
case 0:
generatedTextView.setGravity(17);
break;
case 1:
case 2:
generatedTextView.setGravity(19);
break;
case 3:
generatedTextView.setGravity(21);
break;
}
generatedTextView.setLayoutParams(layoutParams);
Typeface font = AppearanceManager.getCommonInstance().getFont(element.secondaryFont, element.bold, element.italic);
boolean z15 = element.bold;
if (element.italic) {
i17 = 2;
}
if (font == null) {
font = generatedTextView.getTypeface();
}
generatedTextView.setTypeface(font, (z15 ? 1 : 0) + i17);
return generatedTextView;
}
static GeneratedVideoView generateVideo(Element element, Context context, int i15, int i16) {
RelativeLayout.LayoutParams layoutParams;
GeneratedVideoView generatedVideoView = new GeneratedVideoView(context);
if (element.geometry.expand) {
layoutParams = new RelativeLayout.LayoutParams(-1, -1);
} else {
float f15 = i16;
Geometry geometry = element.geometry;
float f16 = i15;
RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams((int) ((geometry.width / 100.0f) * f15), (int) ((geometry.height / 100.0f) * f16));
Geometry geometry2 = element.geometry;
layoutParams2.setMargins((int) ((geometry2.f31568x / 100.0f) * f15), (int) ((geometry2.f31569y / 100.0f) * f16), 0, 0);
layoutParams = layoutParams2;
}
generatedVideoView.setLayoutParams(layoutParams);
return generatedVideoView;
}
public static void loadContent(Element element, GeneratedView generatedView, SimpleViewCallback simpleViewCallback, String str) {
String str2 = element.type;
str2.hashCode();
char c15 = 65535;
switch (str2.hashCode()) {
case -1083981670:
if (str2.equals(TYPE_TEXT_LINK)) {
c15 = 0;
break;
}
break;
case 3321850:
if (str2.equals(TYPE_LINK)) {
c15 = 1;
break;
}
break;
case 3556653:
if (str2.equals("text")) {
c15 = 2;
break;
}
break;
case 100313435:
if (str2.equals(TYPE_IMAGE)) {
c15 = 3;
break;
}
break;
case 112202875:
if (str2.equals("video")) {
c15 = 4;
break;
}
break;
}
switch (c15) {
case 0:
case 1:
loadLink(element, generatedView, simpleViewCallback);
return;
case 2:
loadText(element, generatedView);
return;
case 3:
loadImage(element, generatedView, str);
return;
case 4:
loadVideo(element, generatedView, str);
return;
default:
return;
}
}
static void loadImage(Element element, GeneratedView generatedView, String str) {
File file;
String str2 = element.path;
ArrayList<Source> arrayList = element.sources;
if (arrayList != null && arrayList.size() > 0) {
Iterator<Source> it = element.sources.iterator();
while (it.hasNext()) {
Source next = it.next();
if (next.type.contains("webp")) {
str2 = next.path;
}
}
}
try {
file = InAppStoryService.getInstance().getCommonCache().getFullFile(prePath + str2);
} catch (Exception e15) {
e15.printStackTrace();
file = null;
}
if (file == null) {
ImageLoader.getInstance().displayImage(prePath + str2, -1, (GeneratedImageView) generatedView.view, InAppStoryService.getInstance().getCommonCache());
return;
}
((GeneratedImageView) generatedView.view).setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath(), new BitmapFactory.Options()));
((GeneratedImageView) generatedView.view).onLoaded();
}
static void loadLink(Element element, GeneratedView generatedView, SimpleViewCallback simpleViewCallback) {
generatedView.view.setOnClickListener(new a(element, simpleViewCallback));
}
static void loadText(Element element, GeneratedView generatedView) {
}
static void loadVideo(Element element, GeneratedView generatedView, String str) {
Thumbnail thumbnail = element.thumbnail;
if (thumbnail != null && thumbnail.path != null) {
((GeneratedVideoView) generatedView.view).loadCover(prePath + element.thumbnail.path);
}
ArrayList<Source> arrayList = element.sources;
if (arrayList != null && arrayList.size() > 0) {
((GeneratedVideoView) generatedView.view).loadVideo(prePath + element.sources.get(0).path, str);
}
}
}