company.class
myDb = new DatabaseHelper(this);
if ((item.equals("Bausing, Ian Lester G.")) || (item.equals("Coronel, Diana O.")) || (item.equals("Del Mundo, Chuckie P.")) || (item.equals("Macaspac, John Chris P.")) || (item.equals("Manalac, Romari C. ")) || (item.equals("Navarro, Joshua Calib O.")) || (item.equals("Vitangcul, Melvin P.")) || (item.equals("Querubin, Geo Isaiah M.")) || (item.equals("Ramos, Adrian Revo P.")))
{
Cursor res = myDb.getAllData();
if (res.getCount() == 0) {
showMessage("Error", "Nothing found");
return;
}
dateArray = new String[1000];
timeInArray = new String[1000];
timeOutArray = new String[1000];
idArray = new Integer[1000];
StringBuffer buffer = new StringBuffer();
resState = false;
indexCount_final = 0;
while (res.moveToNext()) {
buffer.append(" Date : " + res.getString(1) + "\n");
buffer.append(" Time In : " + res.getString(2) + "\n");
buffer.append(" Time Out : " + res.getString(3) + "\n");
buffer.append(" Hours Used : " + res.getString(5) + "\n");
buffer.append("Comments : " + res.getString(4) + "\n" + "\n");
if (res.getString(6).equals(username)) {
if(resState_2 == true)
{
firstRowIndex = res.getString(0);
resState_2 = false;
lastIndex_state = false;
}
idArray[arrayIndex] = Integer.parseInt(res.getString(0));
dateArray[arrayIndex] = res.getString(1);
timeInArray[arrayIndex] = res.getString(2);
timeOutArray[arrayIndex] = res.getString(3);
arrayIndex = arrayIndex + 1;
resSatte_3 = true;
}
else if((resSatte_3 == true) && (res.getString(6).equals(username)) == false){
if(lastIndex_state == false) {
lastRowIndex = String.valueOf(res.getString(0));
lastIndex_state = true;
}
indexCount = ((Integer.parseInt(lastRowIndex))) - Integer.parseInt(firstRowIndex);
resState = false;
indexCount_final = indexCount_final + indexCount;
resSatte_3 = false;
resState = true;
resState_2 = true;
}
}
if(lastIndex_state == false)
{
res.moveToLast();
lastRowIndex = String.valueOf(res.getString(0));
//***this part***//
indexCount_final = indexCount_final + indexCount;
//**** to this part ***/
}
init_table();
}
}
});
List<String> categories = new ArrayList<String>();
categories.add("Name of Trainees");
categories.add("Manalac, Romari C. ");
categories.add("Navarro, Joshua Calib O.");
categories.add("Querubin, Geo Isaiah M.");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, categories);
dataAdapter.setDropDownViewResource(R.layout.spinner_item);
name_spinner.setAdapter(dataAdapter);
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
After I login, and then when I try to choose a name on dropdown list the application is crashing. I put a comment which part I having an error.
I'm trying to do is, after I select name in dropdown list. It will display the records of the select name on dropdown list. Currently I'm using Firebase.
here's my initTable
public void init_table() {
TableLayout stk = (TableLayout) findViewById(R.id.table_main);
TableRow tbrow0 = new TableRow(this);
TextView tv1 = new TextView(this);
tv1.setText(" Date ");
tv1.setTextColor(Color.BLACK);
tv1.setTextAppearance(this, android.R.style.TextAppearance_DeviceDefault_Medium);
tbrow0.addView(tv1);
TextView tv2 = new TextView(this);
tv2.setText(" Time In ");
tv2.setTextColor(Color.BLACK);
tv2.setTextAppearance(this, android.R.style.TextAppearance_DeviceDefault_Medium);
tbrow0.addView(tv2);
TextView tv3 = new TextView(this);
tv3.setText(" Time Out ");
tv3.setTextColor(Color.BLACK);
tv3.setTextAppearance(this, android.R.style.TextAppearance_DeviceDefault_Medium);
tbrow0.addView(tv3);
stk.addView(tbrow0);
for (int i = 0; i < (indexCount_final); i++) {
TableRow tbrow = new TableRow(this);
TextView t2v = new TextView(this);
t2v.setText(dateArray[i]);
t2v.setTextColor(Color.BLACK);
t2v.setGravity(Gravity.CENTER);
tbrow.addView(t2v);
TextView t3v = new TextView(this);
t3v.setText(timeInArray[i]);
t3v.setTextColor(Color.BLACK);
t3v.setGravity(Gravity.CENTER);
tbrow.addView(t3v);
TextView t4v = new TextView(this);
t4v.setText(timeOutArray[i]);
t4v.setTextColor(Color.BLACK);
t4v.setGravity(Gravity.CENTER);
tbrow.addView(t4v);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
Button btnEdit = new Button(this);
btnEdit.setText("Button " + i);
btnEdit.setId(i + 1);
final int id_ = btnEdit.getId();
btnEdit.setText("Edit");
btnEdit.setTextColor(Color.BLACK);
tbrow.addView(btnEdit);
btnEdit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "ID Clicked is " + String.valueOf(id_), Toast.LENGTH_SHORT).show();
Cursor res = myDb.getAllData();
if (res.getCount() == 0) {
// show message
showMessage("Error", "Nothing found");
return;
}
while (res.moveToNext()) {
if (res.getString(0).equals(String.valueOf(id_))) {
date_selected = res.getString(1);
timeIn_selected = res.getString(2);
timeOut_selected = res.getString(3);
hours_rend_selected = res.getString(4);
comment_selected = res.getString(5);
name_selected = res.getString(6);
}
}
LayoutInflater li = LayoutInflater.from(context);
View promptsView = li.inflate(R.layout.prompts_company, null);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
alertDialogBuilder.setView(promptsView);
final EditText userInput = (EditText) promptsView
.findViewById(R.id.editTextDialogUserInput);
txtTimeIn = (TextView) promptsView.findViewById(R.id.txtTimeIn);
txtTimeOut = (TextView) promptsView.findViewById(R.id.txtTimeOut);
txtTimeIn.setText(timeIn_selected);
txtTimeOut.setText(timeOut_selected);
btnIn = (Button) promptsView.findViewById(R.id.btnTimeIn_company);
btnOut = (Button) promptsView.findViewById(R.id.btnTimeOut_company);
timePicker_company = (TimePicker) promptsView.findViewById(R.id.timePicker_company);
alertDialogBuilder
.setCancelable(false)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
myDb.updateData(String.valueOf(id_), date_selected, timeIn_selected, timeOut_selected, hours_rend_selected, comment_selected, name_selected);
init_table();
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface
dialog, int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
});
stk.addView(tbrow);
}
}
Having problem on "indexCount_final = indexCount_final + indexCount;"
The app is crashing when already select name on dropdown list
If you post the crash log, there might be a great help to find the reason of crash.
In my guess, I think you should close the Cursor res.
If you don't close the cursor, StrictMode invokes the crash for preventing the leak.
i searched a lot to find how initialize Time variables in my Android project, i have tried to use Set(); methode but doesn't work, i need your help thank's ` here is my source code :
TableRow tableRow;
Time HourProgram;
int H = 12000, M = 1200;
int averageConsultationTime = 30;
// String
// TableSettinHourgHeader=""+HourBegen+"H"+averageConsultationTime+"|"
// +HourBegen+"H"+averageConsultationTime+"|"
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.table);
Log.i("OK", "onCreateOK");
Log.i("OK", "HMOK");
TextView DynamicButton = new TextView(MainActivity.this);
tableRow = (TableRow) findViewById(R.id.tr1);
LayoutParams layoutparams = new TableRow.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
DynamicButton.setLayoutParams(layoutparams);
String ss = converteur(H, M);
Log.i("OK", "converteur(H, M)OK" + ss);
DynamicButton.setText("Assalam Aleikum " + ss);
Log.i("OK", "setTextOK" + ss);
tableRow.addView(DynamicButton);
}
#SuppressWarnings("unused")
private String converteur(int timeBegen, int averageConsultationTime) {
String sTb = "" + String.valueOf(timeBegen).toString();
String sAct = ""
+ String.valueOf(this.averageConsultationTime).toString();
// Toast.makeText(this,
// ""+timeBegen+"H"+averageConsultationTime,Toast.LENGTH_LONG);
return "timeBegen : " + sTb + " averageConsultationTime : "
+ averageConsultationTime;
}
`
For
java.sql.Time
It should be
Time HourProgram = new Time(System.currentTimeMillis());
Also, if you prefer Calendar then,
Time HourProgram = new Time(Calendar.getInstance().getTimeInMillis());
I have the list of images in horizontal LinearLayout If I click particular image the same image will appear on the above of single image view.
How can I get the position of Images in Image View.
CODE
JSONArray multipleimage = alertObj.getJSONArray(PRODUCT_IMAGES);
/*JSONObject singleimage = multipleimage.getJSONObject(Integer.parseInt("original_res"));
String singleimg = productpath + alertObj.getString("seller_id") + String.valueOf(singleimage);
firstimages=(ImageView)
findViewById(R.id.singleimage);
YelloPage.imageLoader.displayImage(singleimg,firstimages,options);*/
horizontalimage=(LinearLayout) findViewById(R.id.linearimage);
if(multipleimage.length()>0)
{
for (int j = 0; j < multipleimage.length(); j++) {
JSONObject pimages = multipleimage.getJSONObject(j);
JSONObject oneimage = multipleimage.getJSONObject(0);
ii = new ImageView(singleshooppingcart.this);
multipleimages = (ImageView) findViewById(R.id.singleimage);
ii.setScaleType(ImageView.ScaleType.FIT_CENTER);
LinearLayout.LayoutParams image = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
image.width = 150;
image.height = 150;
image.setMargins(5, 0, 0, 0);
String multimgs = pimages.getString("original_res");
String oneimg = oneimage.getString("original_res");
String[] img2 = multimgs.split("\\.");
String imagone = productpath + alertObj.getString("seller_id") + '/' + img2[0] + '(' + '2' + '0' + '0' + ')' + '.' + img2[1];
String singleiamges = productpath + alertObj.getString("seller_id") + '/' + oneimg;
YelloPage.imageLoader.displayImage(imagone, ii, options);
YelloPage.imageLoader.displayImage(singleiamges, multipleimages, options);
ii.setLayoutParams(image);
horizontalimage.addView(ii);
ii.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
}
});
}
}
How to solve this problem Thanks in Advance.
You can use many approaches for this-
Simplest approach is using ViewGroup#indexOfChild(View child) method. This will simply return what you want.
Or you can use View#setTag(Object) and View#getTag(), specially if you want to get some thing more than mere index in onClick.
You can also use View#setTag(int, Object) and View#getTag(int), if you want to set more than one tag per view.
Hope below example code for first approach helps-
ii.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick (View view){
// the parameter view here is your imageview, which is clicked.
// horizontalimage is your LinearLayout, which is a ViewGroup
int indexOfImage = horizontalimage.indexOfChild(view);
// do what you want to do with index
}
});
Not tested..try like this...
JSONArray multipleimage = alertObj.getJSONArray(PRODUCT_IMAGES);
/*JSONObject singleimage = multipleimage.getJSONObject(Integer.parseInt("original_res"));
String singleimg = productpath + alertObj.getString("seller_id") + String.valueOf(singleimage);
firstimages = (ImageView)findViewById(R.id.singleimage);
YelloPage.imageLoader.displayImage(singleimg,firstimages,options);*/
horizontalimage = (LinearLayout)findViewById(R.id.linearimage);
if(multipleimage.length()>0)
{
for (int j = 0; j < multipleimage.length(); j++) {
JSONObject pimages = multipleimage.getJSONObject(j);
JSONObject oneimage = multipleimage.getJSONObject(0);
ii = new ImageView(singleshooppingcart.this);
multipleimages = (ImageView) findViewById(R.id.singleimage);
ii.setScaleType(ImageView.ScaleType.FIT_CENTER);
LinearLayout.LayoutParams image = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
image.width = 150;
image.height = 150;
image.setMargins(5, 0, 0, 0);
String multimgs = pimages.getString("original_res");
String oneimg = oneimage.getString("original_res");
String[] img2 = multimgs.split("\\.");
String imagone = productpath + alertObj.getString("seller_id") + '/' + img2[0] + '(' + '2' + '0' + '0' + ')' + '.' + img2[1];
String singleiamges = productpath + alertObj.getString("seller_id") + '/' + oneimg;
YelloPage.imageLoader.displayImage(imagone, ii, options);
YelloPage.imageLoader.displayImage(singleiamges, multipleimages, options);
ii.setLayoutParams(image);
horizontalimage.addView(ii);
ii.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
multipleimages.setImageURI (singleiamges);
}
});
}
}
In my "FilterChoice" activity, I create the layout dynamically. I create a Radio Group and add Radio Buttons in it depending on the size of an ArrayList. There's a list in my "Filters" activity. The radio buttons are different depending on the filters clicked. When I click "Prices" filter, it views six items on the "FilterChoice" activity. Then pressing back button, when I click "Categories" filter, the checkedId's in the onCheckedChanged() starts from seven, instead of one. Why does it not start from one in the new activity call? How to solve it? Here's my "FilterChoice" activity.
`
public class FilterChoice extends AppCompatActivity {
RadioButton rb;
String filter;
String selection, domain, temp;
RadioGroup rg;
public static ArrayList<KeyValuePair> cate_old;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout linearLayout = new LinearLayout(FilterChoice.this);
LinearLayout.LayoutParams lrp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
linearLayout.setLayoutParams(lrp);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
// rb = new RadioButton(FilterChoice.this);
// rb.setText("All");
// rg.addView(rb);
Intent intent = getIntent();
filter = intent.getExtras().getString("filter");
if (filter.equals("Price Range")) {
rg = new RadioGroup(FilterChoice.this);
rg.setLayoutParams(lp);
if (SearchResults.prices.size() == 1) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.price_s_sel + "-"
+ SearchResults.price_e_sel + " ("
+ SearchResults.price_val + ")");
rg.addView(rb);
} else {
int it;
for (it = 0; it < SearchResults.prices.size() - 1; it++) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.prices.get(it).key + "-"
+ SearchResults.prices.get(it + 1).key + " ("
+ SearchResults.prices.get(it).value + ")");
rg.addView(rb);
}
rb = new RadioButton(FilterChoice.this);
rb.setText("Above" + SearchResults.prices.get(it).key + " ("
+ SearchResults.prices.get(it).value + ")");
rg.addView(rb);
}
} else if (filter.equals("Sites")) {
rg = new RadioGroup(FilterChoice.this);
rg.setLayoutParams(lp);
if (SearchResults.site.size() == 1) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.site_sel + " ("
+ SearchResults.site_val + ")");
rg.addView(rb);
// }
} else {
StringTokenizer st;
for (int i = 0; i < SearchResults.site.size(); i++) {
st = new StringTokenizer(SearchResults.site.get(i).key, ".");
if (st.hasMoreTokens()) {
domain = st.nextToken();
}
rb = new RadioButton(FilterChoice.this);
rb.setText(domain + " (" + SearchResults.site.get(i).value
+ ")");
rg.addView(rb);
}
}
} else if (filter.equals("Categories")) {
rg = new RadioGroup(FilterChoice.this);
rg.setLayoutParams(lp);
if (SearchResults.cate.size() == 1) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.cate_sel + " ("
+ SearchResults.cate_val + ")");
rg.addView(rb);
// }
} else {
for (int i = 0; i < SearchResults.cate.size(); i++) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.cate.get(i).key + " ("
+ SearchResults.cate.get(i).value + ")");
rg.addView(rb);
}
}
} else if (filter.equals("Colors")) {
rg = new RadioGroup(FilterChoice.this);
rg.setLayoutParams(lp);
if (SearchResults.cols.size() == 1) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.cols_sel + " ("
+ SearchResults.cols_val + ")");
rg.addView(rb);
} else {
for (int i = 0; i < SearchResults.cols.size(); i++) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.cols.get(i).key + " ("
+ SearchResults.cols.get(i).value + ")");
rg.addView(rb);
}
}
} else if (filter.equals("Brands")) {
rg = new RadioGroup(FilterChoice.this);
rg.setLayoutParams(lp);
if (SearchResults.brands.size() == 1) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.brand_sel + " ("
+ SearchResults.brand_val + ")");
rg.addView(rb);
} else {
for (int i = 0; i < SearchResults.brands.size(); i++) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.brands.get(i).key + " ("
+ SearchResults.brands.get(i).value + ")");
rg.addView(rb);
}
}
} else if (filter.equals("Sub Categories")) {
rg = new RadioGroup(FilterChoice.this);
rg.setLayoutParams(lp);
if (SearchResults.subcate.size() == 1) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.subcate_sel + " ("
+ SearchResults.subcate_val + ")");
rg.addView(rb);
} else {
for (int i = 0; i < SearchResults.subcate.size(); i++) {
rb = new RadioButton(FilterChoice.this);
rb.setText(SearchResults.subcate.get(i).key + " ("
+ SearchResults.subcate.get(i).value + ")");
rg.addView(rb);
}
}
}
linearLayout.addView(rg);
setContentView(linearLayout);
rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (filter.equals("Price Range")) {
} else if (filter.equals("Sites")) {
Log.e("checkedId", "" + checkedId);
if (SearchResults.site.size() > 1) {
selection = SearchResults.site.get(checkedId - 1).key;
temp = SearchResults.site.get(0).key;
SearchResults.site_sel = selection;
SearchResults.site_val = SearchResults.site
.get(checkedId - 1).value;
SearchResults.site_id = checkedId;
}
} else if (filter.equals("Categories")) {
Log.e("checkedId", "" + checkedId);
if (SearchResults.cate.size() > 1) {
selection = SearchResults.cate.get(checkedId - 1).key;
temp = SearchResults.cate.get(0).key;
SearchResults.cate_sel = selection;
SearchResults.cate_val = SearchResults.cate
.get(checkedId - 1).value;
SearchResults.cate_id = checkedId;
}
} else if (filter.equals("Colors")) {
Log.e("checkedId", "" + checkedId);
if (SearchResults.cols.size() > 1) {
selection = SearchResults.cols.get(checkedId - 1).key;
temp = SearchResults.cols.get(0).key;
SearchResults.cols_sel = selection;
SearchResults.cols_val = SearchResults.cols
.get(checkedId - 1).value;
SearchResults.cols_id = checkedId;
}
} else if (filter.equals("Brands")) {
Log.e("checkedId", "" + checkedId);
if (SearchResults.brands.size() > 1) {
selection = SearchResults.brands.get(checkedId - 1).key;
temp = SearchResults.brands.get(0).key;
SearchResults.brand_sel = selection;
SearchResults.brand_val = SearchResults.brands
.get(checkedId - 1).value;
SearchResults.brand_id = checkedId;
}
} else if (filter.equals("Sub Categories")) {
Log.e("checkedId", "" + checkedId);
if (SearchResults.subcate.size() > 1) {
selection = SearchResults.subcate.get(checkedId - 1).key;
temp = SearchResults.subcate.get(0).key;
SearchResults.subcate_sel = selection;
SearchResults.subcate_val = SearchResults.subcate
.get(checkedId - 1).value;
SearchResults.subcate_id = checkedId;
}
}
Intent intent = new Intent(FilterChoice.this, Filters.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
}
}
`
I have not yet figured out the behavior you describe, but I would point out that you can set the IDs of the RadioButtons you're creating dynamically. For example, in your "Categories" block:
for (int i = 0; i < SearchResults.cate.size(); i++) {
rb = new RadioButton(FilterChoice.this);
rb.setId(i + 1);
rb.setText(SearchResults.cate.get(i).key + " ("
+ SearchResults.cate.get(i).value + ")");
rg.addView(rb);
}
This will set IDs from 1 to SearchResults.cate.size(), which I believe is what you're going for.
I have a listview which inflates 4 different types of row layouts depending on the position(overriden getViewTypeCount() and getItemViewType(int position) to achieve it) .Each row has an Image and other textviews and buttons . I am loading the image in a seaparate thread . I am using android viewholder pattern to cache the viewholders for each row type .
When I scroll from one kind of row layout to another row layout I observe a jerkiness in scrolling .
Any pointers to improve will be appreciated.
public View getView(int arg0, View arg1, ViewGroup arg2) {
int width = (Utils.getWidth(mCtx)-Utils.dpToPx(40, mCtx)) ;
final FeedViewData mFeedViewData = getFeedViewData().get(arg0);
if( getItemViewType(arg0) == Utils.SMALL_OBJECT_LEFT){
ObjectViewHolder viewHolderLeft = new ObjectViewHolder() ;
float imgWidth = (width-Utils.dpToPx(1, mCtx))*(0.6f);
float descWidth = (width-Utils.dpToPx(1, mCtx))*(0.4f) ;
float rowHeight = (width-Utils.dpToPx(1, mCtx))*(0.6f)*Utils.PRODUCT_PRI_ASPECT_RATIO;
if(arg1==null){
LayoutInflater inflater = ((Activity)mCtx).getLayoutInflater();
arg1 = inflater.inflate(R.layout.view_multipane_left_image, arg2, false);
viewHolderLeft.row = arg1.findViewById(R.id.rowLayout);
viewHolderLeft.imagesLayout = (RelativeLayout)arg1.findViewById(R.id.layout_image);
viewHolderLeft.objImg = (ImageView)arg1.findViewById(R.id.img_object);
viewHolderLeft.price = (TextView)arg1.findViewById(R.id.text_price);
viewHolderLeft.paneMargin = arg1.findViewById(R.id.pane_margin);
viewHolderLeft.descriptionsLayout = (LinearLayout)arg1.findViewById(R.id.layout_description);
viewHolderLeft.likeActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_like);
viewHolderLeft.likeCount = (TextView)arg1.findViewById(R.id.text_like_count);
viewHolderLeft.shareActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_share);
viewHolderLeft.shareCount = (TextView)arg1.findViewById(R.id.text_share_count);
viewHolderLeft.commentActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_comment);
viewHolderLeft.commentCount = (TextView)arg1.findViewById(R.id.text_share_comment);
viewHolderLeft.activityLayout = (LinearLayout)arg1.findViewById(R.id.layout_activity);
viewHolderLeft.userImg = (ImageView)arg1.findViewById(R.id.img_user);
viewHolderLeft.userActivity = (TextView)arg1.findViewById(R.id.text_activity);
viewHolderLeft.timeline = (TextView)arg1.findViewById(R.id.text_timeline);
RelativeLayout.LayoutParams imgLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams((int)imgWidth,(int)rowHeight));
imgLp.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
viewHolderLeft.objImg.setLayoutParams(imgLp);
RelativeLayout.LayoutParams rlLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams((int)imgWidth,(int)rowHeight));
rlLp.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
rlLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT,RelativeLayout.TRUE);
viewHolderLeft.imagesLayout.setLayoutParams(rlLp);
RelativeLayout.LayoutParams marginLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams(Utils.dpToPx(1,mCtx),(int)rowHeight));
marginLp.addRule(RelativeLayout.RIGHT_OF,R.id.layout_image);
viewHolderLeft.paneMargin.setLayoutParams(marginLp);
RelativeLayout.LayoutParams descLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams((int)descWidth,(int)rowHeight));
descLp.addRule(RelativeLayout.RIGHT_OF,R.id.pane_margin);
descLp.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
viewHolderLeft.descriptionsLayout.setLayoutParams(descLp);
ImageSizeUtils.defineTargetSizeForView(viewHolderLeft.objImg, (int)imgWidth,(int)rowHeight);
arg1.setTag(viewHolderLeft);
}
else{
viewHolderLeft = (ObjectViewHolder)arg1.getTag();
ImageSizeUtils.defineTargetSizeForView(viewHolderLeft.objImg, (int)imgWidth,(int)rowHeight);
}
String mLeftImgUrl = null;
mLeftImgUrl = Utils.m_img_base_url+
mFeedViewData.getProductId() + "/pri-" + mFeedViewData.getFileidn()+".jpg";
try{
ImageLoader.getInstance().displayImage(mLeftImgUrl, viewHolderLeft.objImg,
new SingleImageListener(mFeedViewData,viewHolderLeft.objImg));
}
catch(Exception e){
return null;
}
viewHolderLeft.objImg.setOnClickListener(new ProdImageOnClickListener(mFeedViewData));
if(mFeedViewData.getIsLoved())
viewHolderLeft.likeActionLayout.setBackgroundColor(mCtx.getResources().getColor(R.color.auth_btn_color_normal));
else
viewHolderLeft.likeActionLayout.setBackgroundResource(R.drawable.selector_pink_button);
viewHolderLeft.likeActionLayout.setOnClickListener(new LikeActionListener(mFeedViewData,viewHolderLeft.likeActionLayout));
viewHolderLeft.shareActionLayout.setOnClickListener(new ShareClickListener(mLeftImgUrl));
viewHolderLeft.commentActionLayout.setOnClickListener(new OnCommentClickListener(mFeedViewData));
viewHolderLeft.price.setTypeface(Utils.getFontForRupeeSymb(mCtx));
viewHolderLeft.price.setText(Html.fromHtml( "` " + "</font>" + "<b>" + mFeedViewData.getPrice() + "</b>"));
if(!mFeedViewData.getLikeCount().equals("0"))
viewHolderLeft.likeCount.setText(" (" + mFeedViewData.getLikeCount() + ")");
if(!mFeedViewData.getShareCount().equals("0"))
viewHolderLeft.shareCount.setText(" (" + mFeedViewData.getShareCount() + ")");
if(!mFeedViewData.getRevCount().equals("0"))
viewHolderLeft.commentCount.setText(" (" + mFeedViewData.getRevCount() + ")");
int minutes=0;
if(mFeedViewData.getTimestamp()!=""){
long timeDiff = System.currentTimeMillis() - Long.parseLong(mFeedViewData.getTimestamp());
minutes = (int)((int) (timeDiff/1000))/60;
}
if(mFeedViewData.getUsername().length()>0){
ImageLoader.getInstance().displayImage(mFeedViewData.getTnPic(), viewHolderLeft.userImg,new UserImageListener(viewHolderLeft.userImg));
String activityText = Html.fromHtml("<b>" + mFeedViewData.getUsername() + "</b>" + " "+ mFeedViewData.getActivity()).toString();
SpannableString ss = new SpannableString(activityText);
ss.setSpan(new MyClickableSpan(activityText, mFeedViewData.getDoer()), 0, mFeedViewData.getUsername().length(), Spanned.SPAN_COMPOSING);
viewHolderLeft.userActivity.setText(ss);
if(minutes!=0){
viewHolderLeft.timeline.setText( minutes + " minutes ago");
}
viewHolderLeft.userActivity.setMovementMethod(LinkMovementMethod.getInstance());
}
else if(mFeedViewData.getReview()!=null){
ImageLoader.getInstance().displayImage(mFeedViewData.getReview().getTnUrl(), viewHolderLeft.userImg,new UserImageListener(viewHolderLeft.userImg));
String activityText = Html.fromHtml("<b>" + mFeedViewData.getReview().getReviewerName() + "</b>" + " "+ mFeedViewData.getReview().getReview()).toString();
SpannableString ss = new SpannableString(activityText);
ss.setSpan(new MyClickableSpan(activityText, mFeedViewData.getReview().getId()), 0, mFeedViewData.getReview().getReviewerName().length(), Spanned.SPAN_COMPOSING);
viewHolderLeft.userActivity.setText(ss);
if(minutes!=0){
viewHolderLeft.timeline.setText( minutes + " minutes ago");
}
viewHolderLeft.userActivity.setMovementMethod(LinkMovementMethod.getInstance());
}
else if(mFeedViewData.getActivity().length()>0){
String activityText;
if(mFeedViewData.getActivity().equals("null"))
activityText = Html.fromHtml("<b>" + "A user: "+ "</b>" + "" +" ").toString();
else
activityText = Html.fromHtml("<b>" + "A user: "+ "</b>" + "" +" "+ mFeedViewData.getActivity()).toString();
viewHolderLeft.userActivity.setText(activityText);
if(minutes!=0){
viewHolderLeft.timeline.setText( minutes + " minutes ago");
}
viewHolderLeft.userImg.setImageResource(R.drawable.ic_blank_profile);
}
if(feedType == Utils.ADAPTER_FEED_TUTORIAL){
viewHolderLeft.userActivity.setClickable(false);
viewHolderLeft.objImg.setClickable(false);
}
}
else if(getItemViewType(arg0) == Utils.SMALL_OBJECT_RIGHT){
ObjectViewHolder viewHolderRight = new ObjectViewHolder();
float imgWidth = (width-Utils.dpToPx(1, mCtx))*(0.6f);
float descWidth = (width-Utils.dpToPx(1, mCtx))*(0.4f) ;
float rowHeight = (width-Utils.dpToPx(1, mCtx))*(0.6f)*Utils.PRODUCT_PRI_ASPECT_RATIO;
if(arg1==null){
LayoutInflater inflater = ((Activity)mCtx).getLayoutInflater();
arg1 = inflater.inflate(R.layout.view_multipane_right_image, arg2, false);
viewHolderRight.row = arg1.findViewById(R.id.rowLayout);
viewHolderRight.imagesLayout = (RelativeLayout)arg1.findViewById(R.id.layout_image);
viewHolderRight.objImg = (ImageView)arg1.findViewById(R.id.img_object);
viewHolderRight.price = (TextView)arg1.findViewById(R.id.text_price);
viewHolderRight.paneMargin = arg1.findViewById(R.id.pane_margin);
viewHolderRight.descriptionsLayout = (LinearLayout)arg1.findViewById(R.id.layout_description);
viewHolderRight.likeActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_like);
viewHolderRight.likeCount = (TextView)arg1.findViewById(R.id.text_like_count);
viewHolderRight.shareActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_share);
viewHolderRight.shareCount = (TextView)arg1.findViewById(R.id.text_share_count);
viewHolderRight.commentActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_comment);
viewHolderRight.commentCount = (TextView)arg1.findViewById(R.id.text_share_comment);
viewHolderRight.activityLayout = (LinearLayout)arg1.findViewById(R.id.layout_activity);
viewHolderRight.userImg = (ImageView)arg1.findViewById(R.id.img_user);
viewHolderRight.userActivity = (TextView)arg1.findViewById(R.id.text_activity);
viewHolderRight.timeline = (TextView)arg1.findViewById(R.id.text_timeline);
RelativeLayout.LayoutParams descLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams((int)descWidth,(int)rowHeight));
descLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT,RelativeLayout.TRUE);
descLp.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
viewHolderRight.descriptionsLayout.setLayoutParams(descLp);
RelativeLayout.LayoutParams marginLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams(Utils.dpToPx(1,mCtx),(int)rowHeight));
marginLp.addRule(RelativeLayout.RIGHT_OF,R.id.layout_description);
viewHolderRight.paneMargin.setLayoutParams(marginLp);
RelativeLayout.LayoutParams imgLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams((int)imgWidth,(int)rowHeight));
imgLp.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
viewHolderRight.objImg.setLayoutParams(imgLp);
RelativeLayout.LayoutParams rlLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams((int)imgWidth,(int)rowHeight));
rlLp.addRule(RelativeLayout.RIGHT_OF,R.id.pane_margin);
rlLp.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
viewHolderRight.imagesLayout.setLayoutParams(rlLp);
ImageSizeUtils.defineTargetSizeForView(viewHolderRight.objImg, (int)imgWidth,(int)rowHeight);
arg1.setTag(viewHolderRight);
}
else{
viewHolderRight = (ObjectViewHolder)arg1.getTag();
ImageSizeUtils.defineTargetSizeForView(viewHolderRight.objImg, (int)imgWidth,(int)rowHeight);
}
String mRightImgUrl = null;
mRightImgUrl = Utils.m_img_base_url+
mFeedViewData.getProductId() + "/pri-" + mFeedViewData.getFileidn()+".jpg";
try{
ImageLoader.getInstance().displayImage(mRightImgUrl, viewHolderRight.objImg,
new SingleImageListener(mFeedViewData,viewHolderRight.objImg));
}
catch(Exception e){
return null;
}
viewHolderRight.objImg.setOnClickListener(new ProdImageOnClickListener(mFeedViewData));
if(mFeedViewData.getIsLoved())
viewHolderRight.likeActionLayout.setBackgroundColor(mCtx.getResources().getColor(R.color.auth_btn_color_normal));
else
viewHolderRight.likeActionLayout.setBackgroundResource(R.drawable.selector_pink_button);
viewHolderRight.likeActionLayout.setOnClickListener(new LikeActionListener(mFeedViewData,viewHolderRight.likeActionLayout));
viewHolderRight.shareActionLayout.setOnClickListener(new ShareClickListener(mRightImgUrl));
viewHolderRight.commentActionLayout.setOnClickListener(new OnCommentClickListener(mFeedViewData));
viewHolderRight.price.setTypeface(Utils.getFontForRupeeSymb(mCtx));
viewHolderRight.price.setText(Html.fromHtml( "` " + "</font>" + "<b>" + mFeedViewData.getPrice() + "</b>"));
if(!mFeedViewData.getLikeCount().equals("0"))
viewHolderRight.likeCount.setText(" (" + mFeedViewData.getLikeCount() + ")");
if(!mFeedViewData.getShareCount().equals("0"))
viewHolderRight.shareCount.setText(" (" + mFeedViewData.getShareCount() + ")");
if(!mFeedViewData.getRevCount().equals("0"))
viewHolderRight.commentCount.setText(" (" + mFeedViewData.getRevCount() + ")");
int minutes=0;
if(mFeedViewData.getTimestamp()!=""){
long timeDiff = System.currentTimeMillis() - Long.parseLong(mFeedViewData.getTimestamp());
minutes = (int)((int) (timeDiff/1000))/60;
}
if(mFeedViewData.getUsername().length()>0){
ImageLoader.getInstance().displayImage(mFeedViewData.getTnPic(), viewHolderRight.userImg,new UserImageListener(viewHolderRight.userImg));
String activityText = Html.fromHtml("<b>" + mFeedViewData.getUsername() + "</b>" + " "+ mFeedViewData.getActivity()).toString();
SpannableString ss = new SpannableString(activityText);
ss.setSpan(new MyClickableSpan(activityText, mFeedViewData.getDoer()), 0, mFeedViewData.getUsername().length(), Spanned.SPAN_COMPOSING);
viewHolderRight.userActivity.setText(ss);
if(minutes!=0){
viewHolderRight.timeline.setText( minutes + " minutes ago");
}
viewHolderRight.userActivity.setMovementMethod(LinkMovementMethod.getInstance());
}
else if(mFeedViewData.getReview()!=null){
ImageLoader.getInstance().displayImage(mFeedViewData.getReview().getTnUrl(), viewHolderRight.userImg,new UserImageListener(viewHolderRight.userImg));
String activityText = Html.fromHtml("<b>" + mFeedViewData.getReview().getReviewerName() + "</b>" + " "+ mFeedViewData.getReview().getReview()).toString();
SpannableString ss = new SpannableString(activityText);
ss.setSpan(new MyClickableSpan(activityText, mFeedViewData.getReview().getId()), 0, mFeedViewData.getReview().getReviewerName().length(), Spanned.SPAN_COMPOSING);
viewHolderRight.userActivity.setText(ss);
if(minutes!=0){
viewHolderRight.timeline.setText( minutes + " minutes ago");
}
viewHolderRight.userActivity.setMovementMethod(LinkMovementMethod.getInstance());
}
else if(mFeedViewData.getActivity().length()>0){
String activityText = Html.fromHtml("<b>" + "A user: "+ "</b>" + " "+ mFeedViewData.getActivity()).toString();
viewHolderRight.userActivity.setText(activityText);
if(minutes!=0){
viewHolderRight.timeline.setText( minutes + " minutes ago");
}
viewHolderRight.userImg.setImageResource(R.drawable.ic_blank_profile);
}
if(feedType == Utils.ADAPTER_FEED_TUTORIAL){
viewHolderRight.userActivity.setClickable(false);
viewHolderRight.objImg.setClickable(false);
}
}
else if(getItemViewType(arg0) == Utils.MAGAZINE_OBJECT){
MagazineViewHolder viewHolderMag = new MagazineViewHolder();
float imgWidth = width/2;
float descWidth = width;
float rowHeight = ((width)/2)*Utils.MAG_ASPECT_RATIO;
if(arg1==null){
LayoutInflater inflater = ((Activity)mCtx).getLayoutInflater();
arg1 = inflater.inflate(R.layout.view_magazine, arg2, false);
viewHolderMag.row = arg1.findViewById(R.id.rowLayout);
viewHolderMag.imagesLayout = (RelativeLayout)arg1.findViewById(R.id.layout_image);
viewHolderMag.magImgLeft = (ImageView)arg1.findViewById(R.id.img_object_1);
viewHolderMag.magImgRight = (ImageView)arg1.findViewById(R.id.img_object_2);
viewHolderMag.price = (TextView)arg1.findViewById(R.id.text_price);
viewHolderMag.likeActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_like);
viewHolderMag.likeCount = (TextView)arg1.findViewById(R.id.text_like_count);
viewHolderMag.shareActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_share);
viewHolderMag.shareCount = (TextView)arg1.findViewById(R.id.text_share_count);
viewHolderMag.commentActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_comment);
viewHolderMag.commentCount = (TextView)arg1.findViewById(R.id.text_share_comment);
viewHolderMag.activityLayout = (LinearLayout)arg1.findViewById(R.id.layout_activity);
viewHolderMag.userImg = (ImageView)arg1.findViewById(R.id.img_user);
viewHolderMag.userActivity = (TextView)arg1.findViewById(R.id.text_activity);
viewHolderMag.timeline = (TextView)arg1.findViewById(R.id.text_timeline);
LinearLayout.LayoutParams imgLp1 = new LinearLayout.LayoutParams(
new LinearLayout.LayoutParams((int)imgWidth,(int)rowHeight));
imgLp1.gravity = Gravity.CENTER;
viewHolderMag.magImgLeft.setLayoutParams(imgLp1);
viewHolderMag.magImgRight.setLayoutParams(imgLp1);
RelativeLayout.LayoutParams rlLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams((int)descWidth,(int)rowHeight));
viewHolderMag.imagesLayout.setLayoutParams(rlLp);
ImageSizeUtils.defineTargetSizeForView(viewHolderMag.magImgLeft,(int) imgWidth,(int)rowHeight);
ImageSizeUtils.defineTargetSizeForView(viewHolderMag.magImgRight,(int) imgWidth,(int)rowHeight);
arg1.setTag(viewHolderMag);
}
else{
viewHolderMag = (MagazineViewHolder)arg1.getTag();
ImageSizeUtils.defineTargetSizeForView(viewHolderMag.magImgLeft,(int) imgWidth,(int)rowHeight);
ImageSizeUtils.defineTargetSizeForView(viewHolderMag.magImgRight,(int) imgWidth,(int)rowHeight);
}
String mImgUrlLeft = Utils.m_img_mag_base_url+mFeedViewData.getFileidn().split("-")[1]+".jpg";
String mImgUrlRight = Utils.m_img_mag_base_url+mFeedViewData.getFileidn().split("-")[2];
try{
ImageLoader.getInstance().displayImage(mImgUrlLeft, viewHolderMag.magImgLeft,
new MagazineImageListener(viewHolderMag.magImgLeft));
ImageLoader.getInstance().displayImage(mImgUrlRight, viewHolderMag.magImgRight,
new MagazineImageListener(viewHolderMag.magImgRight));
}
catch(Exception e){
return null;
}
viewHolderMag.imagesLayout.setOnClickListener(new ProdImageOnClickListener(mFeedViewData));
viewHolderMag.price.setTypeface(Utils.getFontForRupeeSymb(mCtx));
viewHolderMag.price.setText(Html.fromHtml( "` " + "</font>" + "<b>" + mFeedViewData.getPrice() + "</b>"));
//TODO: Remove once mag has price
viewHolderMag.price.setVisibility(View.GONE);
if(!mFeedViewData.getLikeCount().equals("0"))
viewHolderMag.likeCount.setText(" (" + mFeedViewData.getLikeCount() + ")");
if(!mFeedViewData.getShareCount().equals("0"))
viewHolderMag.shareCount.setText(" (" + mFeedViewData.getShareCount() + ")");
if(!mFeedViewData.getRevCount().equals("0"))
viewHolderMag.commentCount.setText(" (" + mFeedViewData.getRevCount() + ")");
if(mFeedViewData.getIsLoved())
viewHolderMag.likeActionLayout.setBackgroundColor(mCtx.getResources().getColor(R.color.auth_btn_color_normal));
else
viewHolderMag.likeActionLayout.setBackgroundResource(R.drawable.selector_pink_button);
viewHolderMag.shareActionLayout.setOnClickListener(new ShareClickListener(mFeedViewData.getMagImage()));
viewHolderMag.likeActionLayout.setOnClickListener(new LikeActionListener(mFeedViewData,viewHolderMag.likeActionLayout));
viewHolderMag.commentActionLayout.setOnClickListener(new OnCommentClickListener(mFeedViewData));
int minutes=0;
if(mFeedViewData.getTimestamp()!=""){
long timeDiff = System.currentTimeMillis() - Long.parseLong(mFeedViewData.getTimestamp());
minutes = (int)((int) (timeDiff/1000))/60;
}
if(mFeedViewData.getUsername().length()>0){
ImageLoader.getInstance().displayImage(mFeedViewData.getTnPic(), viewHolderMag.userImg,new UserImageListener(viewHolderMag.userImg));
String activityText = Html.fromHtml("<b>" + mFeedViewData.getUsername() + "</b>" + " "+ mFeedViewData.getActivity()).toString();
SpannableString ss = new SpannableString(activityText);
ss.setSpan(new MyClickableSpan(activityText, mFeedViewData.getDoer()), 0, mFeedViewData.getUsername().length(), Spanned.SPAN_COMPOSING);
viewHolderMag.userActivity.setText(ss);
if(minutes!=0){
viewHolderMag.timeline.setText( minutes + " minutes ago");
}
viewHolderMag.userActivity.setMovementMethod(LinkMovementMethod.getInstance());
}
else if(mFeedViewData.getReview()!=null){
ImageLoader.getInstance().displayImage(mFeedViewData.getReview().getTnUrl(), viewHolderMag.userImg,new UserImageListener(viewHolderMag.userImg));
String activityText = Html.fromHtml("<b>" + mFeedViewData.getReview().getReviewerName() + "</b>" + " "+ mFeedViewData.getReview().getReview()).toString();
SpannableString ss = new SpannableString(activityText);
ss.setSpan(new MyClickableSpan(activityText, mFeedViewData.getReview().getId()), 0, mFeedViewData.getReview().getReviewerName().length(), Spanned.SPAN_COMPOSING);
viewHolderMag.userActivity.setText(ss);
if(minutes!=0){
viewHolderMag.timeline.setText( minutes + " minutes ago");
}
viewHolderMag.userActivity.setMovementMethod(LinkMovementMethod.getInstance());
}
else if(mFeedViewData.getActivity().length()>0){
String activityText = Html.fromHtml("<b>" + "A user: "+ "</b>" + " "+ mFeedViewData.getActivity()).toString();
viewHolderMag.userActivity.setText(activityText);
if(minutes!=0){
viewHolderMag.timeline.setText( minutes + " minutes ago");
}
viewHolderMag.userImg.setImageResource(R.drawable.ic_blank_profile);
}
if(feedType == Utils.ADAPTER_FEED_TUTORIAL){
viewHolderMag.userActivity.setClickable(false);
viewHolderMag.imagesLayout.setClickable(false);
}
}
else if(getItemViewType(arg0) == Utils.SCRAP_OBJECT){
ObjectViewHolder viewHolderScrap = new ObjectViewHolder();
float imgWidth = width;
float rowHeight = (width)*Utils.SCRAPBOOK_ASPECT_RATIO;
if(arg1==null){
LayoutInflater inflater = ((Activity)mCtx).getLayoutInflater();
arg1 = inflater.inflate(R.layout.view_single_pane, arg2, false);
viewHolderScrap.row = arg1.findViewById(R.id.rowLayout);
viewHolderScrap.imagesLayout = (RelativeLayout)arg1.findViewById(R.id.layout_image);
viewHolderScrap.objImg = (ImageView)arg1.findViewById(R.id.img_object);
viewHolderScrap.price = (TextView)arg1.findViewById(R.id.text_price);
viewHolderScrap.likeActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_like);
viewHolderScrap.likeCount = (TextView)arg1.findViewById(R.id.text_like_count);
viewHolderScrap.shareActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_share);
viewHolderScrap.shareCount = (TextView)arg1.findViewById(R.id.text_share_count);
viewHolderScrap.commentActionLayout = (RelativeLayout)arg1.findViewById(R.id.layout_action_comment);
viewHolderScrap.commentCount = (TextView)arg1.findViewById(R.id.text_share_comment);
viewHolderScrap.activityLayout = (LinearLayout)arg1.findViewById(R.id.layout_activity);
viewHolderScrap.userImg = (ImageView)arg1.findViewById(R.id.img_user);
viewHolderScrap.userActivity = (TextView)arg1.findViewById(R.id.text_activity);
viewHolderScrap.timeline = (TextView)arg1.findViewById(R.id.text_timeline);
RelativeLayout.LayoutParams imgLp1 = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams((int)imgWidth,(int)rowHeight));
viewHolderScrap.objImg.setLayoutParams(imgLp1);
RelativeLayout.LayoutParams rlLp = new RelativeLayout.LayoutParams(
new RelativeLayout.LayoutParams((int)imgWidth,(int)rowHeight));
viewHolderScrap.imagesLayout.setLayoutParams(rlLp);
ImageSizeUtils.defineTargetSizeForView(viewHolderScrap.objImg,(int) imgWidth,(int)rowHeight);
arg1.setTag(viewHolderScrap);
}
else{
viewHolderScrap = (ObjectViewHolder)arg1.getTag();
ImageSizeUtils.defineTargetSizeForView(viewHolderScrap.objImg,(int) imgWidth,(int)rowHeight);
}
String mNormalImgUrl = null;
mNormalImgUrl = Utils.m_img_scrap_base_url + mFeedViewData.getScrapId() + ".png";
try{
ImageLoader.getInstance().displayImage(mNormalImgUrl, viewHolderScrap.objImg,
new SingleImageListener(mFeedViewData,viewHolderScrap.objImg));
}
catch(Exception e){
return null;
}
viewHolderScrap.objImg.setOnClickListener(new ProdImageOnClickListener(mFeedViewData));
if(mFeedViewData.getIsLoved())
viewHolderScrap.likeActionLayout.setBackgroundColor(mCtx.getResources().getColor(R.color.auth_btn_color_normal));
else
viewHolderScrap.likeActionLayout.setBackgroundResource(R.drawable.selector_pink_button);
viewHolderScrap.likeActionLayout.setOnClickListener(new LikeActionListener(mFeedViewData,viewHolderScrap.likeActionLayout));
viewHolderScrap.shareActionLayout.setOnClickListener(new ShareClickListener(mNormalImgUrl));
viewHolderScrap.commentActionLayout.setOnClickListener(new OnCommentClickListener(mFeedViewData));
viewHolderScrap.price.setTypeface(Utils.getFontForRupeeSymb(mCtx));
viewHolderScrap.price.setText(Html.fromHtml( "` " + "</font>" + "<b>" + mFeedViewData.getPrice() + "</b>"));
//TODO:Remove once scrap has price
viewHolderScrap.price.setVisibility(View.GONE);
if(!mFeedViewData.getLikeCount().equals("0"))
viewHolderScrap.likeCount.setText(" (" + mFeedViewData.getLikeCount() + ")");
if(!mFeedViewData.getShareCount().equals("0"))
viewHolderScrap.shareCount.setText(" (" + mFeedViewData.getShareCount() + ")");
if(!mFeedViewData.getRevCount().equals("0"))
viewHolderScrap.commentCount.setText(" (" + mFeedViewData.getRevCount() + ")");
int minutes=0;
if(mFeedViewData.getTimestamp()!=""){
long timeDiff = System.currentTimeMillis() - Long.parseLong(mFeedViewData.getTimestamp());
minutes = (int)((int) (timeDiff/1000))/60;
}
if(mFeedViewData.getUsername().length()>0 && (!mFeedViewData.getActivity().equals("null")) && mFeedViewData.getActivity().length()>0){
ImageLoader.getInstance().displayImage(mFeedViewData.getTnPic(), viewHolderScrap.userImg,new UserImageListener(viewHolderScrap.userImg));
String activityText = Html.fromHtml("<b>" + mFeedViewData.getUsername() + "</b>" + " "+ mFeedViewData.getActivity()).toString();
SpannableString ss = new SpannableString(activityText);
ss.setSpan(new MyClickableSpan(activityText, mFeedViewData.getDoer()), 0, mFeedViewData.getUsername().length(), Spanned.SPAN_COMPOSING);
viewHolderScrap.userActivity.setText(ss);
if(minutes!=0){
viewHolderScrap.timeline.setText( minutes + " minutes ago");
}
viewHolderScrap.userActivity.setMovementMethod(LinkMovementMethod.getInstance());
}
else if(mFeedViewData.getReview()!=null){
ImageLoader.getInstance().displayImage(mFeedViewData.getReview().getTnUrl(), viewHolderScrap.userImg,new UserImageListener(viewHolderScrap.userImg));
String activityText = Html.fromHtml("<b>" + mFeedViewData.getReview().getReviewerName() + "</b>" + " "+ mFeedViewData.getReview().getReview()).toString();
SpannableString ss = new SpannableString(activityText);
ss.setSpan(new MyClickableSpan(activityText, mFeedViewData.getReview().getId()), 0, mFeedViewData.getReview().getReviewerName().length(), Spanned.SPAN_COMPOSING);
viewHolderScrap.userActivity.setText(ss);
if(minutes!=0){
viewHolderScrap.timeline.setText( minutes + " minutes ago");
}
viewHolderScrap.userActivity.setMovementMethod(LinkMovementMethod.getInstance());
}
else if(mFeedViewData.getActivity().length()>0){
String activityText = Html.fromHtml("<b>" + "A user: "+ "</b>" + " "+ mFeedViewData.getActivity()).toString();
viewHolderScrap.userActivity.setText(activityText);
if(minutes!=0){
viewHolderScrap.timeline.setText( minutes + " minutes ago");
}
viewHolderScrap.userImg.setImageResource(R.drawable.ic_blank_profile);
}
if(feedType == Utils.ADAPTER_FEED_TUTORIAL){
viewHolderScrap.userActivity.setClickable(false);
viewHolderScrap.objImg.setClickable(false);
}
}
return arg1;
}
Make sure you do not load or process any images in Adapter.getView() method. If you need to do so, do it in a separate AsyncTask. If you download images from Internet you should better use some helper libraries like Volley or Picasso
I use this library to load images in list view, I never had a problem:Android Image Loader