Skip to main content
formatting fix
Source Link
Siddharth
  • 9.6k
  • 19
  • 93
  • 158

Edit : Please note : I have removed most of the repeated code to keep the question light. But have ensured that relevantThe code is there for you to help. Thanksas per viewHolder layout.

public class RideAdapter extends ArrayAdapter<String[]> {// implements // OnClickListener { private Context rootActivity; private static LayoutInflater rowInflater = null; private String rideSummary[][]; private Animation moveRight, moveLeft; public RideAdapter(Context rootActivity, String[][] rideSummary) { super(rootActivity, R.layout.ride, rideSummary); this.rootActivity = rootActivity; this.rideSummary = rideSummary; } public int getCount() { return rideSummary.length; } public View getView(int position, View convertView, ViewGroup parent) { RideRow row = null; if (convertView == null) { rowInflater = LayoutInflater.from(rootActivity.getApplicationContext()); convertView = rowInflater.inflate(R.layout.ride, parent, false); row = new RideRow(position); row.row = (RelativeLayout) convertView.findViewById(R.id.row); // //All findViewById calls // row.accept.setOnClickListener(row); // // All setOnTouchListener // convertView.setTag(row); } row = (RideRow) convertView.getTag(); // // All setText's // row.rideDistance.setText(rideSummary[position][RIDE_DISTANCE]); return convertView; } @Override public String[] getItem(int position) { return rideSummary[position]; } @Override public long getItemId(int position) { return 0; } public class RideRow implements OnClickListener, OnTouchListener { public RelativeLayout row; // //All textviews in the row // private int position; public RideRow(int newPosition) { position = newPosition; moveRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, // fromXType 0.0f, // fromXValue Animation.RELATIVE_TO_PARENT, // toXType 1.0f, // toXValue Animation.RELATIVE_TO_SELF, // fromYType 0.0f, // fromYValue Animation.RELATIVE_TO_SELF, // toYType 0.0f); moveRight.setDuration(1000); moveLeft = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, // fromXType 0.0f, // fromXValue Animation.RELATIVE_TO_PARENT, // toXType -1.0f, // toXValue Animation.RELATIVE_TO_SELF, // fromYType 0.0f, // fromYValue Animation.RELATIVE_TO_SELF, // toYType 0.0f); moveLeft.setDuration(1000); } @Override public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.accept: showCustomerContact(); break; // // All events // default: break; } } @Override public boolean onTouch(View v, MotionEvent event) { int id = v.getId(); switch (id) { case R.id.accept: showCustomerContact(); break; default: break; } return true; } private void showCustomerContact() { moveRight.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { rideSummaryLayout.setVisibility(View.GONE); callRideLayout.setVisibility(View.VISIBLE); swipeToReject.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); swipeToAccept.setVisibility(View.INVISIBLE); accept.startAnimation(moveRight); FlurryAgent.logEvent(God.SHOW_CUSTOMER_DETAILS) ; } private void showRideSummary() { //Similar to showCustomerContact() FlurryAgent.logEvent(God.SHOW_RIDE_SUMMARY) ; } private void doCallCustomer() { // Place Call to customer FlurryAgent.logEvent(God.CALLED_CUSTOMER) ; } } } 

Edit : Please note : I have removed most of the repeated code to keep the question light. But have ensured that relevant code is there for you to help. Thanks.

public class RideAdapter extends ArrayAdapter<String[]> {// implements // OnClickListener { private Context rootActivity; private static LayoutInflater rowInflater = null; private String rideSummary[][]; private Animation moveRight, moveLeft; public RideAdapter(Context rootActivity, String[][] rideSummary) { super(rootActivity, R.layout.ride, rideSummary); this.rootActivity = rootActivity; this.rideSummary = rideSummary; } public int getCount() { return rideSummary.length; } public View getView(int position, View convertView, ViewGroup parent) { RideRow row = null; if (convertView == null) { rowInflater = LayoutInflater.from(rootActivity.getApplicationContext()); convertView = rowInflater.inflate(R.layout.ride, parent, false); row = new RideRow(position); row.row = (RelativeLayout) convertView.findViewById(R.id.row); // //All findViewById calls // row.accept.setOnClickListener(row); // // All setOnTouchListener // convertView.setTag(row); } row = (RideRow) convertView.getTag(); // // All setText's // row.rideDistance.setText(rideSummary[position][RIDE_DISTANCE]); return convertView; } @Override public String[] getItem(int position) { return rideSummary[position]; } @Override public long getItemId(int position) { return 0; } public class RideRow implements OnClickListener, OnTouchListener { public RelativeLayout row; // //All textviews in the row // private int position; public RideRow(int newPosition) { position = newPosition; moveRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, // fromXType 0.0f, // fromXValue Animation.RELATIVE_TO_PARENT, // toXType 1.0f, // toXValue Animation.RELATIVE_TO_SELF, // fromYType 0.0f, // fromYValue Animation.RELATIVE_TO_SELF, // toYType 0.0f); moveRight.setDuration(1000); moveLeft = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, // fromXType 0.0f, // fromXValue Animation.RELATIVE_TO_PARENT, // toXType -1.0f, // toXValue Animation.RELATIVE_TO_SELF, // fromYType 0.0f, // fromYValue Animation.RELATIVE_TO_SELF, // toYType 0.0f); moveLeft.setDuration(1000); } @Override public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.accept: showCustomerContact(); break; // // All events // default: break; } } @Override public boolean onTouch(View v, MotionEvent event) { int id = v.getId(); switch (id) { case R.id.accept: showCustomerContact(); break; default: break; } return true; } private void showCustomerContact() { moveRight.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { rideSummaryLayout.setVisibility(View.GONE); callRideLayout.setVisibility(View.VISIBLE); swipeToReject.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); swipeToAccept.setVisibility(View.INVISIBLE); accept.startAnimation(moveRight); FlurryAgent.logEvent(God.SHOW_CUSTOMER_DETAILS) ; } private void showRideSummary() { //Similar to showCustomerContact() FlurryAgent.logEvent(God.SHOW_RIDE_SUMMARY) ; } private void doCallCustomer() { // Place Call to customer FlurryAgent.logEvent(God.CALLED_CUSTOMER) ; } } } 

Edit : The code is as per viewHolder layout.

edited for accuracy
Source Link
Siddharth
  • 9.6k
  • 19
  • 93
  • 158

Edit : Please note : I have removed most of the repeated code to keep the question light. But have ensured that relevant code is there for you to help. Thanks.

public class RideAdapter extends ArrayAdapter<String[]> {// implements // OnClickListener { private Context rootActivity; private static LayoutInflater rowInflater = null; private String rideSummary[][]; private Animation moveRight, moveLeft; public RideAdapter(Context rootActivity, String[][] rideSummary) { super(rootActivity, R.layout.ride, rideSummary); this.rootActivity = rootActivity; this.rideSummary = rideSummary; } public int getCount() { return rideSummary.length; } public View getView(int position, View convertView, ViewGroup parent) { RideRow row = null; if (convertView == null) { rowInflater = LayoutInflater.from(rootActivity.getApplicationContext()); convertView = rowInflater.inflate(R.layout.ride, parent, false); row = new RideRow(position); row.row = (RelativeLayout) convertView.findViewById(R.id.row); // //All findViewById calls // row.accept.setOnClickListener(row); // // All setOnTouchListener // convertView.setTag(row); } row = (RideRow) convertView.getTag(); // // All setText's // row.rideDistance.setText(rideSummary[position][RIDE_DISTANCE]); return convertView; } @Override public String[] getItem(int position) { return rideSummary[position]; } @Override public long getItemId(int position) { return 0; } public class RideRow implements OnClickListener, OnTouchListener { public RelativeLayout row; // //All textviews in the row // private int position; public RideRow(int newPosition) { position = newPosition; moveRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, // fromXType 0.0f, // fromXValue Animation.RELATIVE_TO_PARENT, // toXType 1.0f, // toXValue Animation.RELATIVE_TO_SELF, // fromYType 0.0f, // fromYValue Animation.RELATIVE_TO_SELF, // toYType 0.0f); moveRight.setDuration(1000); moveLeft = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, // fromXType 0.0f, // fromXValue Animation.RELATIVE_TO_PARENT, // toXType -1.0f, // toXValue Animation.RELATIVE_TO_SELF, // fromYType 0.0f, // fromYValue Animation.RELATIVE_TO_SELF, // toYType 0.0f); moveLeft.setDuration(1000); } @Override public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.accept: showCustomerContact(); break; // // All events // default: break; } } @Override public boolean onTouch(View v, MotionEvent event) { int id = v.getId(); switch (id) { case R.id.accept: showCustomerContact(); break; default: break; } return true; } private void showCustomerContact() { moveRight.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { rideSummaryLayout.setVisibility(View.GONE); callRideLayout.setVisibility(View.VISIBLE); swipeToReject.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); swipeToAccept.setVisibility(View.INVISIBLE); accept.startAnimation(moveRight); FlurryAgent.logEvent(God.SHOW_CUSTOMER_DETAILS) ; } private void showRideSummary() { //Similar to showCustomerContact() FlurryAgent.logEvent(God.SHOW_RIDE_SUMMARY) ; } private void doCallCustomer() { // Place Call to customer FlurryAgent.logEvent(God.CALLED_CUSTOMER) ; } } } 

Edit : Please note : I have removed most of the repeated code to keep the question light. But have ensured that relevant code is there for you to help. Thanks.

public class RideAdapter extends ArrayAdapter<String[]> {// implements // OnClickListener { private Context rootActivity; private static LayoutInflater rowInflater = null; private String rideSummary[][]; private Animation moveRight, moveLeft; public RideAdapter(Context rootActivity, String[][] rideSummary) { super(rootActivity, R.layout.ride, rideSummary); this.rootActivity = rootActivity; this.rideSummary = rideSummary; } public int getCount() { return rideSummary.length; } public View getView(int position, View convertView, ViewGroup parent) { RideRow row = null; if (convertView == null) { rowInflater = LayoutInflater.from(rootActivity.getApplicationContext()); convertView = rowInflater.inflate(R.layout.ride, parent, false); row = new RideRow(position); row.row = (RelativeLayout) convertView.findViewById(R.id.row); // //All findViewById calls // row.accept.setOnClickListener(row); // // All setOnTouchListener // convertView.setTag(row); } row = (RideRow) convertView.getTag(); // // All setText's // row.rideDistance.setText(rideSummary[position][RIDE_DISTANCE]); return convertView; } @Override public String[] getItem(int position) { return rideSummary[position]; } @Override public long getItemId(int position) { return 0; } public class RideRow implements OnClickListener, OnTouchListener { public RelativeLayout row; // //All textviews in the row // private int position; public RideRow(int newPosition) { position = newPosition; moveRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, // fromXType 0.0f, // fromXValue Animation.RELATIVE_TO_PARENT, // toXType 1.0f, // toXValue Animation.RELATIVE_TO_SELF, // fromYType 0.0f, // fromYValue Animation.RELATIVE_TO_SELF, // toYType 0.0f); moveRight.setDuration(1000); moveLeft = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, // fromXType 0.0f, // fromXValue Animation.RELATIVE_TO_PARENT, // toXType -1.0f, // toXValue Animation.RELATIVE_TO_SELF, // fromYType 0.0f, // fromYValue Animation.RELATIVE_TO_SELF, // toYType 0.0f); moveLeft.setDuration(1000); } @Override public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.accept: showCustomerContact(); break; // // All events // default: break; } } @Override public boolean onTouch(View v, MotionEvent event) { int id = v.getId(); switch (id) { case R.id.accept: showCustomerContact(); break; default: break; } return true; } private void showCustomerContact() { moveRight.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { rideSummaryLayout.setVisibility(View.GONE); callRideLayout.setVisibility(View.VISIBLE); swipeToReject.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); swipeToAccept.setVisibility(View.INVISIBLE); accept.startAnimation(moveRight); FlurryAgent.logEvent(God.SHOW_CUSTOMER_DETAILS) ; } private void showRideSummary() { //Similar to showCustomerContact() FlurryAgent.logEvent(God.SHOW_RIDE_SUMMARY) ; } private void doCallCustomer() { // Place Call to customer FlurryAgent.logEvent(God.CALLED_CUSTOMER) ; } } } 

ListView ScrollScrolling is not smppthsmooth

Source Link
Siddharth
  • 9.6k
  • 19
  • 93
  • 158
Loading