AvatarStyleFragment.java
11.4 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
package com.bitstrips.imoji.abv3.style;
import android.animation.ArgbEvaluator;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Resources;
import android.graphics.PorterDuff.Mode;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.bitstrips.imoji.InjectorApplication;
import com.bitstrips.imoji.abv3.AvatarBuilderStyle;
import com.bitstrips.imoji.abv3.model.AvatarChangeStyle;
import com.bitstrips.imoji.abv3.model.AvatarSaveResponseV3;
import com.bitstrips.imoji.abv3.model.AvatarStyleConfig;
import com.bitstrips.imoji.abv3.model.AvatarStylePreviouslySaved;
import com.bitstrips.imoji.api.BitmojiApi;
import com.bitstrips.imoji.behaviour.BehaviourHelper;
import com.bitstrips.imoji.persistence.MediaCache;
import com.bitstrips.imoji.ui.BmTypefaceLoader;
import com.bitstrips.imoji.ui.BmTypefaceLoader.OnTypefaceLoadedCallback;
import com.bitstrips.imoji.ui.views.BmButton;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.inject.Inject;
import retrofit.Callback;
import retrofit.RetrofitError;
public class AvatarStyleFragment
extends Fragment
implements AvatarStyleListener
{
private static final String e = AvatarStyleFragment.class.getSimpleName();
List<AvatarStyleConfig> a;
@Inject
BitmojiApi b;
@Inject
MediaCache c;
@Inject
BehaviourHelper d;
private ViewPager f;
private AvatarStyleAdapter g;
private List<ImageView> h;
private TextView i;
private ImageView j;
private BmButton k;
private int l;
private AvatarStylePreviouslySaved m;
public static AvatarStyleFragment createFragment(int paramInt, AvatarStylePreviouslySaved paramAvatarStylePreviouslySaved)
{
Bundle localBundle = new Bundle();
localBundle.putInt("ARGUMENT_AVATAR_CURRENT_STYLE", paramInt);
localBundle.putSerializable("ARGUMENT_AVATAR_STYLE_INFO", paramAvatarStylePreviouslySaved);
paramAvatarStylePreviouslySaved = new AvatarStyleFragment();
paramAvatarStylePreviouslySaved.setArguments(localBundle);
return paramAvatarStylePreviouslySaved;
}
public AvatarStyleFragmentListener getListener()
{
return (AvatarStyleFragmentListener)getActivity();
}
public List<AvatarStyleConfig> getStyleConfigList()
{
Object localObject2 = getResources();
String str2 = ((Resources)localObject2).getString(2131231330);
Object localObject1 = ((Resources)localObject2).getString(2131231329);
String str1 = ((Resources)localObject2).getString(2131231331);
int n = ((Resources)localObject2).getColor(2131624127);
int i1 = ((Resources)localObject2).getColor(2131624126);
int i2 = ((Resources)localObject2).getColor(2131624128);
localObject2 = new AvatarStyleConfig(1, str2, n);
localObject1 = new AvatarStyleConfig(4, (String)localObject1, i1);
return new ArrayList(Arrays.asList(new AvatarStyleConfig[] { new AvatarStyleConfig(5, str1, i2), localObject2, localObject1 }));
}
public void onAttach(Context paramContext)
{
super.onAttach(paramContext);
}
public void onCreate(@Nullable Bundle paramBundle)
{
super.onCreate(paramBundle);
((InjectorApplication)getActivity().getApplication()).inject(this);
this.a = getStyleConfigList();
}
@Nullable
public View onCreateView(LayoutInflater paramLayoutInflater, @Nullable ViewGroup paramViewGroup, @Nullable Bundle paramBundle)
{
paramBundle = new ViewPager.OnPageChangeListener()
{
public final void onPageScrollStateChanged(int paramAnonymousInt) {}
public final void onPageScrolled(int paramAnonymousInt1, float paramAnonymousFloat, int paramAnonymousInt2)
{
if (paramAnonymousInt1 < AvatarStyleFragment.a(AvatarStyleFragment.this).getCount() - 1) {}
for (paramAnonymousInt2 = paramAnonymousInt1 + 1;; paramAnonymousInt2 = paramAnonymousInt1)
{
paramAnonymousInt2 = ((Integer)this.a.evaluate(paramAnonymousFloat, Integer.valueOf(((AvatarStyleConfig)AvatarStyleFragment.this.a.get(paramAnonymousInt1)).getBackgroundColor()), Integer.valueOf(((AvatarStyleConfig)AvatarStyleFragment.this.a.get(paramAnonymousInt2)).getBackgroundColor()))).intValue();
AvatarStyleFragment.b(AvatarStyleFragment.this).setColorFilter(paramAnonymousInt2, PorterDuff.Mode.DST_ATOP);
AvatarStyleFragment.c(AvatarStyleFragment.this).setTextColor(paramAnonymousInt2);
paramAnonymousInt2 = Math.round(paramAnonymousInt1 + paramAnonymousFloat);
paramAnonymousFloat = Math.abs(paramAnonymousInt1 + paramAnonymousFloat - paramAnonymousInt2);
AvatarStyleFragment.d(AvatarStyleFragment.this).setText(((AvatarStyleConfig)AvatarStyleFragment.this.a.get(paramAnonymousInt2)).getTitle());
AvatarStyleFragment.d(AvatarStyleFragment.this).setAlpha(1.0F - AvatarStyleFragment.a(paramAnonymousFloat, 1.0F));
Iterator localIterator = AvatarStyleFragment.e(AvatarStyleFragment.this).iterator();
while (localIterator.hasNext())
{
ImageView localImageView = (ImageView)localIterator.next();
localImageView.getBackground().clearColorFilter();
localImageView.getBackground().setColorFilter(-1, PorterDuff.Mode.DST_ATOP);
localImageView.setAlpha(0.4F);
}
}
((ImageView)AvatarStyleFragment.e(AvatarStyleFragment.this).get(paramAnonymousInt2)).getBackground().setColorFilter(-1, PorterDuff.Mode.DST_ATOP);
paramAnonymousFloat = AvatarStyleFragment.a(paramAnonymousFloat, 0.6F);
((ImageView)AvatarStyleFragment.e(AvatarStyleFragment.this).get(paramAnonymousInt2)).setAlpha(1.0F - paramAnonymousFloat);
}
public final void onPageSelected(int paramAnonymousInt)
{
AvatarStyleFragment.a(AvatarStyleFragment.this, paramAnonymousInt);
}
};
int i1 = getArguments().getInt("ARGUMENT_AVATAR_CURRENT_STYLE");
this.m = ((AvatarStylePreviouslySaved)getArguments().getSerializable("ARGUMENT_AVATAR_STYLE_INFO"));
int n = 0;
if (n < this.a.size()) {
if (((AvatarStyleConfig)this.a.get(n)).getStyleNum() != i1) {}
}
for (;;)
{
paramLayoutInflater = paramLayoutInflater.inflate(2130903110, paramViewGroup, false);
this.j = ((ImageView)paramLayoutInflater.findViewById(2131689723));
paramViewGroup = paramLayoutInflater.findViewById(2131689729);
paramViewGroup.setOnClickListener(new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
AvatarStyleFragment.this.onSaveSelected();
}
});
paramLayoutInflater.findViewById(2131689699).setOnClickListener(new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
paramAnonymousView = AvatarStyleFragment.this.getListener();
if (paramAnonymousView == null) {
return;
}
paramAnonymousView.onStyleExit();
}
});
this.k = ((BmButton)paramViewGroup);
BmTypefaceLoader.getInstance().loadTypefaceStyle(getContext(), 1, new BmTypefaceLoader.OnTypefaceLoadedCallback()
{
public final void onTypefaceLoaded(Typeface paramAnonymousTypeface)
{
AvatarStyleFragment.c(AvatarStyleFragment.this).setTypeface(paramAnonymousTypeface);
}
});
this.i = ((TextView)paramLayoutInflater.findViewById(2131689727));
paramViewGroup = getResources().getDrawable(2130837618);
this.j.setImageDrawable(paramViewGroup);
this.f = ((ViewPager)paramLayoutInflater.findViewById(2131689726));
paramViewGroup = new ArrayList();
Object localObject = this.a.iterator();
for (;;)
{
if (((Iterator)localObject).hasNext())
{
paramViewGroup.add(Integer.valueOf(((AvatarStyleConfig)((Iterator)localObject).next()).getStyleNum()));
continue;
n += 1;
break;
}
}
this.g = new AvatarStyleAdapter(paramViewGroup, this.c, this.m);
this.f.setAdapter(this.g);
this.f.addOnPageChangeListener(paramBundle);
paramViewGroup = (LinearLayout)paramLayoutInflater.findViewById(2131689728);
this.h = new ArrayList();
paramBundle = getResources();
int i2 = paramBundle.getDimensionPixelSize(2131362143);
int i3 = paramBundle.getDimensionPixelSize(2131362142);
i1 = 0;
while (i1 < this.a.size())
{
paramBundle = new ImageView(getContext());
paramBundle.setBackground(getResources().getDrawable(2130837932));
localObject = new LinearLayout.LayoutParams(i2, i2);
((LinearLayout.LayoutParams)localObject).setMargins(i3, 0, i3, 0);
paramBundle.setLayoutParams((ViewGroup.LayoutParams)localObject);
paramViewGroup.addView(paramBundle);
this.h.add(paramBundle);
i1 += 1;
}
this.f.setCurrentItem(n);
this.l = n;
setPercentMeasurements();
return paramLayoutInflater;
n = 0;
}
}
public void onSaveSelected()
{
onStyleSelected(((AvatarStyleConfig)this.a.get(this.l)).getStyleNum());
}
public void onStyleSelected(final int paramInt)
{
boolean bool = false;
Object localObject1 = AvatarBuilderStyle.fromValue(paramInt);
if (getArguments().getInt("ARGUMENT_AVATAR_CURRENT_STYLE") == paramInt)
{
localObject2 = getListener();
if (localObject2 != null) {}
}
do
{
return;
((AvatarStyleFragmentListener)localObject2).onStyleSelected(false, (AvatarBuilderStyle)localObject1);
return;
if (!this.m.isStylePreviouslySaved(paramInt)) {
bool = true;
}
localObject1 = new Callback()
{
public final void failure(RetrofitError paramAnonymousRetrofitError)
{
Log.e(AvatarStyleFragment.a(), "Failed to change user style");
AvatarStyleFragment.b(AvatarStyleFragment.this, paramInt);
}
};
} while ((paramInt == AvatarBuilderStyle.STYLE_CM.getValue()) && (!this.d.isCMSaveEnabled()));
Object localObject2 = new AvatarChangeStyle(paramInt);
this.b.changeAvatarStyleV3((AvatarChangeStyle)localObject2, (Callback)localObject1);
}
public void setPercentMeasurements()
{
DisplayMetrics localDisplayMetrics = getContext().getResources().getDisplayMetrics();
int n = (int)(localDisplayMetrics.widthPixels * 0.85D);
this.f.getLayoutParams().height = n;
n = (localDisplayMetrics.widthPixels - n) / 2;
int i1 = (int)(n * 0.9D);
this.f.setPadding(i1, 0, i1, 0);
this.f.setPageMargin(n / 2);
this.f.setClipToPadding(false);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/abv3/style/AvatarStyleFragment.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/