|
32 | 32 | import android.graphics.BitmapFactory; |
33 | 33 | import android.graphics.Color; |
34 | 34 | import android.os.Bundle; |
| 35 | +import android.os.Handler; |
35 | 36 | import android.support.v4.app.DialogFragment; |
36 | 37 | import android.support.v4.app.Fragment; |
37 | 38 | import android.text.TextUtils; |
@@ -78,6 +79,7 @@ public class IntroductionFragment extends Fragment { |
78 | 79 | private Button mButtonRecip2; |
79 | 80 | private static final String TAG = SafeSlingerConfig.LOG_TAG; |
80 | 81 | private static OnIntroResultListener mResult; |
| 82 | + private Handler mIntroFragmentHandler = new Handler(); |
81 | 83 |
|
82 | 84 | @Override |
83 | 85 | public void onCreate(Bundle savedInstanceState) { |
@@ -146,58 +148,69 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
146 | 148 | } |
147 | 149 |
|
148 | 150 | public void updateValues(Bundle extras) { |
149 | | - // general state |
150 | | - RecipientDbAdapter dbRecipient = RecipientDbAdapter.openInstance(getActivity()); |
151 | | - DraftData d = DraftData.INSTANCE; |
152 | 151 |
|
153 | | - // make sure view is already inflated... |
154 | | - if (mEditTextMessage1 == null) { |
155 | | - return; |
156 | | - } |
| 152 | + mIntroFragmentHandler.removeCallbacks(null); |
| 153 | + mIntroFragmentHandler.postDelayed(new Runnable() { |
157 | 154 |
|
158 | | - // recipient 1 |
159 | | - mImageViewRecipPhoto1.setImageResource(0); |
160 | | - RecipientRow r1 = d.getRecip1(); |
161 | | - if (d.existsRecip1()) { |
162 | | - drawUserData(R.string.label_SendTo, r1.getName(), r1.getPhoto(), mTextViewRecipName1, |
163 | | - mTextViewRecipKey1, mImageViewRecipPhoto1, r1.getKeyid(), r1.getKeydate()); |
164 | | - mTextViewRecipName1.setTextColor(Color.BLACK); |
165 | | - } else { |
166 | | - mTextViewRecipName1.setTextColor(Color.GRAY); |
167 | | - mTextViewRecipName1.setText(R.string.label_SelectRecip); |
168 | | - mTextViewRecipKey1.setText(""); |
169 | | - mImageViewRecipPhoto1.setImageResource(R.drawable.ic_silhouette_select); |
170 | | - } |
| 155 | + @Override |
| 156 | + public void run() { |
171 | 157 |
|
172 | | - // recipient 2 |
173 | | - mImageViewRecipPhoto2.setImageResource(0); |
174 | | - RecipientRow r2 = d.getRecip2(); |
175 | | - if (d.existsRecip2()) { |
176 | | - drawUserData(R.string.label_SendTo, r2.getName(), r2.getPhoto(), mTextViewRecipName2, |
177 | | - mTextViewRecipKey2, mImageViewRecipPhoto2, r2.getKeyid(), r2.getKeydate()); |
178 | | - mTextViewRecipName2.setTextColor(Color.BLACK); |
179 | | - } else { |
180 | | - mTextViewRecipName2.setTextColor(Color.GRAY); |
181 | | - mTextViewRecipName2.setText(R.string.label_SelectRecip); |
182 | | - mTextViewRecipKey2.setText(""); |
183 | | - mImageViewRecipPhoto2.setImageResource(R.drawable.ic_silhouette_select); |
184 | | - } |
| 158 | + // general state |
| 159 | + RecipientDbAdapter dbRecipient = RecipientDbAdapter.openInstance(getActivity()); |
| 160 | + DraftData d = DraftData.INSTANCE; |
185 | 161 |
|
186 | | - // message |
187 | | - if (d.existsRecip1() && d.existsRecip2()) { |
188 | | - // if recip1 and recip2 |
189 | | - mEditTextMessage1.setVisibility(View.VISIBLE); |
190 | | - mEditTextMessage2.setVisibility(View.VISIBLE); |
191 | | - mEditTextMessage1.setText(String.format( |
192 | | - getString(R.string.label_messageIntroduceNameToYou), r2.getName())); |
193 | | - mEditTextMessage2.setText(String.format( |
194 | | - getString(R.string.label_messageIntroduceNameToYou), r1.getName())); |
195 | | - } else { |
196 | | - // if empty.recip1, hide |
197 | | - mEditTextMessage1.setVisibility(View.GONE); |
198 | | - // if empty.recip2, hide |
199 | | - mEditTextMessage2.setVisibility(View.GONE); |
200 | | - } |
| 162 | + // make sure view is already inflated... |
| 163 | + if (mEditTextMessage1 == null) { |
| 164 | + return; |
| 165 | + } |
| 166 | + |
| 167 | + // recipient 1 |
| 168 | + mImageViewRecipPhoto1.setImageResource(0); |
| 169 | + RecipientRow r1 = d.getRecip1(); |
| 170 | + if (d.existsRecip1()) { |
| 171 | + drawUserData(R.string.label_SendTo, r1.getName(), r1.getPhoto(), |
| 172 | + mTextViewRecipName1, mTextViewRecipKey1, mImageViewRecipPhoto1, |
| 173 | + r1.getKeyid(), r1.getKeydate()); |
| 174 | + mTextViewRecipName1.setTextColor(Color.BLACK); |
| 175 | + } else { |
| 176 | + mTextViewRecipName1.setTextColor(Color.GRAY); |
| 177 | + mTextViewRecipName1.setText(R.string.label_SelectRecip); |
| 178 | + mTextViewRecipKey1.setText(""); |
| 179 | + mImageViewRecipPhoto1.setImageResource(R.drawable.ic_silhouette_select); |
| 180 | + } |
| 181 | + |
| 182 | + // recipient 2 |
| 183 | + mImageViewRecipPhoto2.setImageResource(0); |
| 184 | + RecipientRow r2 = d.getRecip2(); |
| 185 | + if (d.existsRecip2()) { |
| 186 | + drawUserData(R.string.label_SendTo, r2.getName(), r2.getPhoto(), |
| 187 | + mTextViewRecipName2, mTextViewRecipKey2, mImageViewRecipPhoto2, |
| 188 | + r2.getKeyid(), r2.getKeydate()); |
| 189 | + mTextViewRecipName2.setTextColor(Color.BLACK); |
| 190 | + } else { |
| 191 | + mTextViewRecipName2.setTextColor(Color.GRAY); |
| 192 | + mTextViewRecipName2.setText(R.string.label_SelectRecip); |
| 193 | + mTextViewRecipKey2.setText(""); |
| 194 | + mImageViewRecipPhoto2.setImageResource(R.drawable.ic_silhouette_select); |
| 195 | + } |
| 196 | + |
| 197 | + // message |
| 198 | + if (d.existsRecip1() && d.existsRecip2()) { |
| 199 | + // if recip1 and recip2 |
| 200 | + mEditTextMessage1.setVisibility(View.VISIBLE); |
| 201 | + mEditTextMessage2.setVisibility(View.VISIBLE); |
| 202 | + mEditTextMessage1.setText(String.format( |
| 203 | + getString(R.string.label_messageIntroduceNameToYou), r2.getName())); |
| 204 | + mEditTextMessage2.setText(String.format( |
| 205 | + getString(R.string.label_messageIntroduceNameToYou), r1.getName())); |
| 206 | + } else { |
| 207 | + // if empty.recip1, hide |
| 208 | + mEditTextMessage1.setVisibility(View.GONE); |
| 209 | + // if empty.recip2, hide |
| 210 | + mEditTextMessage2.setVisibility(View.GONE); |
| 211 | + } |
| 212 | + } |
| 213 | + }, 200); |
201 | 214 | } |
202 | 215 |
|
203 | 216 | private void doClickRecipient1() { |
|
0 commit comments