AvatarBuilderFragment.java
18.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
package com.bitstrips.imoji.abv3;
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import com.bitstrips.imoji.InjectorApplication;
import com.bitstrips.imoji.abv3.camera.AvatarBuilderImageHelper;
import com.bitstrips.imoji.abv3.category.AvatarCategoryContainerView;
import com.bitstrips.imoji.abv3.category.AvatarCategoryDetails;
import com.bitstrips.imoji.abv3.category.AvatarCategoryListener;
import com.bitstrips.imoji.abv3.category.AvatarCategoryProvider;
import com.bitstrips.imoji.abv3.model.AvatarBrand;
import com.bitstrips.imoji.abv3.model.AvatarCategory;
import com.bitstrips.imoji.abv3.model.AvatarLookAlike;
import com.bitstrips.imoji.abv3.model.AvatarOption;
import com.bitstrips.imoji.abv3.preview.AvatarBuilderPreviewListener;
import com.bitstrips.imoji.abv3.preview.AvatarBuilderPreviewMode;
import com.bitstrips.imoji.abv3.preview.AvatarBuilderPreviewView;
import com.bitstrips.imoji.abv3.preview.SaveAnimationWrapper;
import com.bitstrips.imoji.behaviour.BehaviourHelper;
import com.bitstrips.imoji.experiments.Experiments;
import com.bitstrips.imoji.experiments.MirrorUploadHelper;
import com.bitstrips.imoji.persistence.MediaCache;
import com.squareup.picasso.Picasso.LoadedFrom;
import com.squareup.picasso.RequestCreator;
import com.squareup.picasso.Target;
import hg;
import hh;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
public class AvatarBuilderFragment
extends Fragment
implements AvatarCategoryListener, AvatarCategoryProvider, AvatarBuilderPreviewListener
{
private static final int[] f = { 7, 0, 1 };
private static final String g = AvatarBuilderFragment.class.getSimpleName();
private AnimatorSet A;
private WebView B;
@Inject
AvatarBuilderMetricsHelper a;
@Inject
BehaviourHelper b;
@Inject
MediaCache c;
@Inject
MirrorUploadHelper d;
@Inject
Experiments e;
private final AvatarBuilderSelection h = new AvatarBuilderSelection();
private AvatarBuilderUriBuilder i;
private ViewGroup j;
private AvatarBuilderPreviewView k;
private AvatarCategoryContainerView l;
private AvatarBuilderConfig m;
private Uri n;
private Uri o;
private Target p;
private Target q;
private int r = 1;
private boolean s = false;
private boolean t = false;
private View u;
private AnimatorSet v;
private AnimatorSet w;
private boolean x;
private View y;
private AnimatorSet z;
private void b()
{
final SaveAnimationWrapper localSaveAnimationWrapper = new SaveAnimationWrapper(this.j);
if (localSaveAnimationWrapper.getWeight() == getResources().getInteger(2131558409)) {
return;
}
ObjectAnimator localObjectAnimator = ObjectAnimator.ofFloat(localSaveAnimationWrapper, "weight", new float[] { localSaveAnimationWrapper.getWeight(), getResources().getInteger(2131558409) });
localObjectAnimator.setDuration(getResources().getInteger(2131558404));
localObjectAnimator.addListener(new AnimatorListenerAdapter()
{
public final void onAnimationEnd(Animator paramAnonymousAnimator)
{
AvatarBuilderFragment.a();
new StringBuilder("animateToSmallerWeight, animation complete: ").append(localSaveAnimationWrapper.getWeight());
}
});
localObjectAnimator.start();
}
public static AvatarBuilderFragment createFragment(String paramString)
{
Bundle localBundle = new Bundle();
localBundle.putString("ARGUMENT_AVATAR_BUILDER_USER_IMAGE_PATH", paramString);
paramString = new AvatarBuilderFragment();
paramString.setArguments(localBundle);
return paramString;
}
public AvatarCategory getAvatarCategory(@NonNull String paramString)
{
return this.m.getAvatarCategory(paramString);
}
public AvatarCategoryDetails getCurrentAvatarDetails()
{
return this.l.getCurrentAvatarDetails();
}
public String getCurrentCategory()
{
return this.l.getCurrentAvatarDetails().getCategoryKey();
}
public AvatarBuilderGender getGender()
{
return this.m.getGender();
}
public hh getListener()
{
return (hh)getActivity();
}
@NonNull
public List<AvatarBrand> getOutfits()
{
return this.m.getOutfits();
}
public AvatarLookAlike getSelectedLookAlike()
{
return this.h.getLookAlike();
}
public Integer getSelectedOptionValue(@NonNull String paramString)
{
Integer localInteger2 = this.h.getSelectedOption(paramString);
Integer localInteger1 = localInteger2;
if (localInteger2 == null) {
localInteger1 = this.m.getUserOption(paramString);
}
return localInteger1;
}
@NonNull
public Uri getUri(@NonNull AvatarCategoryDetails paramAvatarCategoryDetails, @NonNull AvatarLookAlike paramAvatarLookAlike)
{
return this.i.getLookAlikeUri(paramAvatarCategoryDetails, paramAvatarLookAlike);
}
@NonNull
public Uri getUri(@NonNull AvatarCategoryDetails paramAvatarCategoryDetails, @NonNull AvatarOption paramAvatarOption)
{
return this.i.getOptionUri(paramAvatarCategoryDetails, paramAvatarOption);
}
public boolean hasNewChanges()
{
return this.t;
}
public boolean isColourlessBeard(Integer paramInteger)
{
return this.m.isColourlessBeard(paramInteger);
}
public boolean isColourlessHair(Integer paramInteger)
{
return this.m.isColourlessHair(paramInteger);
}
public boolean isHairTreatmentHair(Integer paramInteger)
{
return this.m.isHairTreatmentHair(paramInteger);
}
public boolean isLiplessMouth(Integer paramInteger)
{
return this.m.isLiplessMouth(paramInteger);
}
public void onActivityCreated(@Nullable Bundle paramBundle)
{
super.onActivityCreated(paramBundle);
this.l.setCategory(this.m.getStartCategory());
reloadPreviewImage();
refreshUserImage();
}
public void onBrandSelected(final AvatarBrand paramAvatarBrand)
{
StringBuilder localStringBuilder = new StringBuilder("onBrandSelected ");
if (paramAvatarBrand == null)
{
localObject = null;
localStringBuilder.append(localObject);
if (paramAvatarBrand != this.h.getSelectedBrand()) {
break label46;
}
}
label46:
do
{
return;
localObject = Integer.valueOf(paramAvatarBrand.getId());
break;
this.h.setBrand(paramAvatarBrand);
} while (paramAvatarBrand == null);
Object localObject = Uri.parse(paramAvatarBrand.mStoreBackground);
this.q = new Target()
{
public final void onBitmapFailed(Drawable paramAnonymousDrawable) {}
public final void onBitmapLoaded(Bitmap paramAnonymousBitmap, Picasso.LoadedFrom paramAnonymousLoadedFrom)
{
if (paramAvatarBrand == AvatarBuilderFragment.c(AvatarBuilderFragment.this).getSelectedBrand()) {
AvatarBuilderFragment.d(AvatarBuilderFragment.this).setBrandBackground(paramAnonymousBitmap);
}
}
public final void onPrepareLoad(Drawable paramAnonymousDrawable) {}
};
this.c.load((Uri)localObject).into(this.q);
}
public void onCategoryChanged()
{
AvatarCategoryDetails localAvatarCategoryDetails = getCurrentAvatarDetails();
new StringBuilder("onCategoryChanged ").append(localAvatarCategoryDetails.getCategoryKey());
reloadPreviewImage();
if ("save".equals(localAvatarCategoryDetails.getCategoryKey()))
{
this.k.setPreviewMode(AvatarBuilderPreviewMode.PREVIEW_FULL_SCREEN_FULL_BODY);
final SaveAnimationWrapper localSaveAnimationWrapper = new SaveAnimationWrapper(this.j);
if (localSaveAnimationWrapper.getWeight() != getResources().getInteger(2131558410))
{
ObjectAnimator localObjectAnimator = ObjectAnimator.ofFloat(localSaveAnimationWrapper, "weight", new float[] { localSaveAnimationWrapper.getWeight(), getResources().getInteger(2131558410) });
localObjectAnimator.setDuration(getResources().getInteger(2131558404));
localObjectAnimator.addListener(new AnimatorListenerAdapter()
{
public final void onAnimationEnd(Animator paramAnonymousAnimator)
{
if ("save".equals(AvatarBuilderFragment.f(AvatarBuilderFragment.this).getCurrentAvatarDetails().getCategoryKey())) {
AvatarBuilderFragment.d(AvatarBuilderFragment.this).animateFlashes();
}
AvatarBuilderFragment.a();
new StringBuilder("animateToLargerWeight, animation complete: ").append(localSaveAnimationWrapper.getWeight());
}
});
localObjectAnimator.start();
}
}
for (;;)
{
if (!"save".equals(localAvatarCategoryDetails.getCategoryKey())) {
this.k.stopFlashes();
}
return;
if ("body".equals(localAvatarCategoryDetails.getPreviewDisplayType()))
{
this.k.setPreviewMode(AvatarBuilderPreviewMode.PREVIEW_FULL_SCREEN_FULL_BODY);
b();
}
else if (this.k.getPreviewMode() == AvatarBuilderPreviewMode.PREVIEW_FULL_SCREEN_FULL_BODY)
{
this.k.setPreviewMode(AvatarBuilderPreviewMode.PREVIEW_FULL_SCREEN);
b();
}
}
}
public void onCreate(@Nullable Bundle paramBundle)
{
super.onCreate(paramBundle);
((InjectorApplication)getContext().getApplicationContext()).inject(this);
this.m = ((hg)getActivity()).getConfig();
this.i = new AvatarBuilderUriBuilder(this.b.getPreviewEndpoint(), "avatar-builder-v3", this.m, this.h, this.b, this.e);
}
@Nullable
public View onCreateView(LayoutInflater paramLayoutInflater, @Nullable ViewGroup paramViewGroup, @Nullable Bundle paramBundle)
{
paramLayoutInflater = paramLayoutInflater.inflate(2130903104, paramViewGroup, false);
paramViewGroup = paramLayoutInflater.findViewById(2131689700);
if (this.m.showTopSaveButton()) {}
for (int i1 = 0;; i1 = 8)
{
paramViewGroup.setVisibility(i1);
paramViewGroup.setOnClickListener(new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
AvatarBuilderFragment.a(AvatarBuilderFragment.this);
}
});
paramLayoutInflater.findViewById(2131689699).setOnClickListener(new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
AvatarBuilderFragment.this.getListener().onExit();
}
});
this.u = paramLayoutInflater.findViewById(2131689698);
this.u.setOnClickListener(new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
AvatarBuilderFragment.this.getListener().onShowCamera();
}
});
this.u.setAlpha(0.0F);
this.u.setScaleX(0.0F);
this.u.setScaleY(0.0F);
this.u.setVisibility(4);
this.x = false;
this.v = ((AnimatorSet)AnimatorInflater.loadAnimator(getContext(), 2131034115));
this.v.setTarget(this.u);
this.w = ((AnimatorSet)AnimatorInflater.loadAnimator(getContext(), 2131034116));
this.w.setTarget(this.u);
this.w.addListener(new AnimatorListenerAdapter()
{
public final void onAnimationEnd(Animator paramAnonymousAnimator)
{
super.onAnimationEnd(paramAnonymousAnimator);
AvatarBuilderFragment.b(AvatarBuilderFragment.this).setVisibility(4);
}
});
this.y = paramLayoutInflater.findViewById(2131689697);
this.y.setAlpha(0.0F);
this.z = ((AnimatorSet)AnimatorInflater.loadAnimator(getContext(), 2131034113));
this.z.setTarget(this.y);
this.A = ((AnimatorSet)AnimatorInflater.loadAnimator(getContext(), 2131034114));
this.A.setTarget(this.y);
if (this.b.isSvgAvatarPreview())
{
this.B = ((WebView)paramLayoutInflater.findViewById(2131689696));
this.B.setVisibility(0);
this.B.setBackgroundColor(0);
if (Build.VERSION.SDK_INT >= 19) {
WebView.setWebContentsDebuggingEnabled(true);
}
this.B.getSettings().setJavaScriptEnabled(true);
this.B.loadDataWithBaseURL("", "<html><head><script>" + "function adjustImage() {var svg = document.getElementsByTagName('svg')[0];svg.setAttribute('style', 'transform:translate(-100px, -180px)');}" + "</script></head><body><script>" + "function fetchSvg(svgUrl) {fetch(svgUrl).then(x => x.text()).then(svgPayload => {document.body.innerHTML = svgPayload;adjustImage();});}" + "</script></body></html>", "text/html", "UTF-8", "");
}
this.j = ((FrameLayout)paramLayoutInflater.findViewById(2131689694));
this.k = ((AvatarBuilderPreviewView)paramLayoutInflater.findViewById(2131689695));
this.k.setListener(this);
this.k.setAnimationsEnabled(true);
this.k.setFullBodyPreviewDecorator(true);
this.l = ((AvatarCategoryContainerView)paramLayoutInflater.findViewById(2131689701));
this.l.setCategoryDetails(this, this, this.m);
return paramLayoutInflater;
}
}
public void onLookAlikeSelected(AvatarLookAlike paramAvatarLookAlike)
{
this.h.setLookAlike(paramAvatarLookAlike);
reloadPreviewImage();
}
public void onLooksLikeMe()
{
this.a.looksLikeMe(this.m.getGender(), this.m.getStyle());
this.l.animateToSecondViewPager(this.m.getBodyCategoryDetails(), this.m.getBodyBottomBarItems());
}
public void onOptionSelected(@NonNull AvatarCategoryDetails paramAvatarCategoryDetails, AvatarOption paramAvatarOption)
{
StringBuilder localStringBuilder = new StringBuilder("onOptionSelected ");
Object localObject;
if (paramAvatarOption == null)
{
localObject = null;
localStringBuilder.append(localObject);
this.t = true;
this.h.setOption(paramAvatarCategoryDetails.getCategoryKey(), paramAvatarOption);
if (("mouth".equals(paramAvatarCategoryDetails.getCategoryKey())) && (isLiplessMouth(Integer.valueOf(paramAvatarOption.getValue())))) {
this.h.setOption("lipstick_tone", null);
}
if (!"hat".equals(paramAvatarCategoryDetails.getCategoryKey())) {
break label120;
}
this.h.setOption("hair_accessory", null);
}
for (;;)
{
reloadPreviewImage();
return;
localObject = Integer.valueOf(paramAvatarOption.getValue());
break;
label120:
if ("hair_accessory".equals(paramAvatarCategoryDetails.getCategoryKey())) {
this.h.setOption("hat", null);
}
}
}
public void onPreviewLeftToRightSwipe()
{
this.s = true;
if (this.r >= 2) {
return;
}
this.r += 1;
reloadPreviewImage();
}
public void onPreviewModeChanged(AvatarBuilderPreviewMode paramAvatarBuilderPreviewMode)
{
if (!this.x) {
if ((paramAvatarBuilderPreviewMode == AvatarBuilderPreviewMode.PREVIEW_MINIMIZED) || (paramAvatarBuilderPreviewMode == AvatarBuilderPreviewMode.SPLIT_VIEW))
{
this.u.setVisibility(0);
this.v.start();
this.z.start();
this.x = true;
}
}
while ((paramAvatarBuilderPreviewMode != AvatarBuilderPreviewMode.PREVIEW_FULL_SCREEN) && (paramAvatarBuilderPreviewMode != AvatarBuilderPreviewMode.PREVIEW_FULL_SCREEN_FULL_BODY)) {
return;
}
this.w.start();
this.A.start();
this.x = false;
}
public void onPreviewPlaceholderTap()
{
getListener().onShowCamera();
}
public void onPreviewRightToLeftSwipe()
{
this.s = true;
if (this.r <= 0) {
return;
}
this.r -= 1;
reloadPreviewImage();
}
public void onPreviewUserImageLongPress()
{
getListener().onShowCamera();
}
public void onResume()
{
super.onResume();
this.k.setUserImageEnabled(true);
}
public void onSave()
{
if (this.h.getSelectedOptionsWithLookAlike().size() > 0) {}
for (boolean bool = true;; bool = false)
{
this.t = bool;
getListener().onSave(this.m, this.h);
return;
}
}
public void onTweak()
{
this.a.tweak(this.m.getGender(), this.m.getStyle());
this.l.animateToSecondViewPager(this.m.getTweakCategoryDetails(), this.m.getTweakBottomBarItems());
}
public boolean refreshOnlyOnVisibility()
{
return !((hg)getActivity()).preloadAdjacentCategories();
}
public void refreshUserImage()
{
Object localObject = getArguments().getString("ARGUMENT_AVATAR_BUILDER_USER_IMAGE_PATH");
if (localObject == null)
{
this.k.setUserImage(null);
return;
}
localObject = AvatarBuilderImageHelper.loadImage((String)localObject);
this.k.setUserImage((Bitmap)localObject);
}
public void reloadPreviewImage()
{
final Object localObject = this.l.getCurrentAvatarDetails();
if (((AvatarCategoryDetails)localObject).getCategoryKey().equals("save"))
{
localObject = this.i.getSaveUri((AvatarCategoryDetails)localObject);
this.p = new Target()
{
public final void onBitmapFailed(Drawable paramAnonymousDrawable) {}
public final void onBitmapLoaded(Bitmap paramAnonymousBitmap, Picasso.LoadedFrom paramAnonymousLoadedFrom)
{
if (localObject.equals(AvatarBuilderFragment.e(AvatarBuilderFragment.this)))
{
AvatarBuilderFragment.d(AvatarBuilderFragment.this).setPreview(paramAnonymousBitmap);
AvatarBuilderFragment.d(AvatarBuilderFragment.this).stopLoading();
AvatarBuilderFragment.a(AvatarBuilderFragment.this, localObject);
}
}
public final void onPrepareLoad(Drawable paramAnonymousDrawable)
{
AvatarBuilderFragment.d(AvatarBuilderFragment.this).startLoading();
}
};
if (!this.b.isSvgAvatarPreview()) {
break label147;
}
this.B.loadUrl("javascript:fetchSvg('" + ((Uri)localObject).toString() + "')");
}
label147:
while (((Uri)localObject).equals(this.n))
{
return;
int i1 = ((AvatarCategoryDetails)localObject).getRotation();
if (this.s) {
i1 = f[this.r];
}
if (this.b.isSvgAvatarPreview())
{
localObject = this.i.getPreviewUri((AvatarCategoryDetails)localObject, i1, "svg");
break;
}
localObject = this.i.getPreviewUri((AvatarCategoryDetails)localObject, i1);
break;
}
new StringBuilder("Reloading: ").append(localObject);
this.o = ((Uri)localObject);
this.c.load((Uri)localObject).into(this.p);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/abv3/AvatarBuilderFragment.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/