List of usage examples for android.view.animation TranslateAnimation setStartTime
public void setStartTime(long startTimeMillis)
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentSearch.java
private void searchFood(final String item, final int page_num) { if (!NetworkConnectionStatus.isNetworkAvailable(getActivity())) { Toast.makeText(getActivity(), "Check your connection and try again", Toast.LENGTH_LONG).show(); } else {// w ww .j av a 2 s . co m mAsyncTask = new AsyncTask<String, String, String>() { @Override protected void onPreExecute() { } @Override protected String doInBackground(String... arg0) { JSONObject food = mFatSecretSearch.searchFood(item, page_num); JSONArray FOODS_ARRAY; try { if (food != null) { FOODS_ARRAY = food.getJSONArray("food"); if (FOODS_ARRAY != null) { for (int i = 0; i < FOODS_ARRAY.length(); i++) { JSONObject food_items = FOODS_ARRAY.optJSONObject(i); String food_name = food_items.getString("food_name"); String food_description = food_items.getString("food_description"); String[] row = food_description.split("-"); String id = food_items.getString("food_type"); if (id.equals("Brand")) { brand = food_items.getString("brand_name"); } if (id.equals("Generic")) { brand = "Generic"; } String food_id = food_items.getString("food_id"); mItem.add(new SearchItemResult(food_name, row[1].substring(1), "" + brand, food_id)); } } } } catch (JSONException exception) { exception.printStackTrace(); return "Error"; } return ""; } @Override protected void onPostExecute(String result) { super.onPostExecute(result); searchAdapter.notifyDataSetChanged(); if (listContainer.getCount() > 0) { searchBack.setVisibility(View.VISIBLE); TranslateAnimation slide = new TranslateAnimation(0, 0, listContainer.getHeight(), 0); slide.setStartTime(1000); listContainer.setVisibility(View.VISIBLE); slide.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); slide.setDuration(400); listContainer.startAnimation(slide); } else { searchBack.setVisibility(View.GONE); listContainer.setVisibility(View.GONE); } } @Override protected void onCancelled() { } }; mAsyncTask.execute(); } }