Thursday 7 June 2012

ZoomByEnterPageActivity.java


package com.qualcomm.QCARSamples.ImageTargets;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.json.JSONArray;
import org.json.JSONException;

import com.devsmart.android.ui.HorizontalListView;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
import android.widget.Toast;

public class ZoomByEnterPageActivity extends Activity implements
OnClickListener {
int i = 0, height, width;

Gallery slideshow;
// RefreshHandler refreshHandler = new RefreshHandler();
static TabHost tabHost;
ImageView iv;
RelativeLayout mainlayout;
RelativeLayout slidingpanel;
RelativeLayout slidinglayout;
Button open, settings, wishlist_btn, triplist_btn, friends_btn, closearrow;
String u_id;
RelativeLayout bl;
ImageView i1, i2, i3, i4;

int total = 10, total_tspot = 1;
LinearLayout.LayoutParams layout_button;
ProgressDialog dialog;
String URL = MainURL.URL + "slideshow";
String URL_tspot = MainURL.URL + "getlist";
String responseBody;
JSONArray jArray, jSubArray;

String[] items;
String[] path, id;
ImageView[] categories;
LinearLayout detaillayout;
String slide;
LayoutInflater inflater;
ImageLoader1 imageLoader;
String responseBody_tspot;
int[] Id;
String[] items_tspot;
String[] thumb_tspot, one_liner_tspot, spot_id_tspot, cat_tspot,
name_tspot, thumb_temp_tspot, one_liner_temp_tspot,
name_temp_tspot, cat_id_tspot, spot_id_temp_tspot;
int k_tspot;

String info_tspot;

HorizontalListView listview;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainfirstscreen);
dialog = ProgressDialog.show(ZoomByEnterPageActivity.this, "",
"Loading Data ...Please Wait", true);

Bundle extras = getIntent().getExtras();

if (extras != null) {

u_id = extras.getString("u_id");

}
height = getWindowManager().getDefaultDisplay().getHeight();
width = getWindowManager().getDefaultDisplay().getWidth();
// Toast.makeText(getApplicationContext(), height + "", 5000).show();
// Toast.makeText(getApplicationContext(), width + "", 5000).show();
bl = (RelativeLayout) findViewById(R.id.buttonlayout);
open = (Button) findViewById(R.id.open);
wishlist_btn = (Button) this.findViewById(R.id.button1);
friends_btn = (Button) this.findViewById(R.id.button2);
triplist_btn = (Button) this.findViewById(R.id.button3);
closearrow = (Button) findViewById(R.id.button22);
settings = (Button) findViewById(R.id.settings);
slidingpanel = (RelativeLayout) findViewById(R.id.slidingpanel);
slidinglayout = (RelativeLayout) findViewById(R.id.slidinglayout);
mainlayout = (RelativeLayout) findViewById(R.id.mainlayout);
mainlayout.setOnClickListener(this);
// slideshow = (Gallery) findViewById(R.id.slideshow);
// slideshow.setAdapter(new ImageAdapter(this));
Button gujarat = (Button) findViewById(R.id.gujarat);
Button augment = (Button) findViewById(R.id.AR);
Button ff = (Button) findViewById(R.id.ff);

Button touristspot = (Button) findViewById(R.id.touristspot);
listview = (HorizontalListView) findViewById(R.id.listview);

// listview.setLayoutParams(new RelativeLayout.LayoutParams(
// getWindowManager().getDefaultDisplay().getWidth(),
// (int) (getWindowManager().getDefaultDisplay().getHeight() / 4.5)));
// //
// MarginLayoutParams marginParams = new MarginLayoutParams(
// listview.getLayoutParams());
// marginParams.setMargins(0, 0, 0, 0);
// RelativeLayout.LayoutParams layoutParams = new
// RelativeLayout.LayoutParams(
// marginParams);
// if (getWindowManager().getDefaultDisplay().getHeight() >= 320) {
// listview.setPadding(0, 0, 0, 0);
// }
// listview.setLayoutParams(layoutParams);
listview.setBackgroundResource(R.drawable.bg_480_800);

mainlayout.getLayoutParams().height = (int) (height * 0.90);

// bl.setLayoutParams(new RelativeLayout.LayoutParams(
// (int) (getWindowManager().getDefaultDisplay().getWidth() * 0.80),
// (int) (getWindowManager().getDefaultDisplay().getHeight() / 2.5)));

MarginLayoutParams marginParams_bl = new MarginLayoutParams(
bl.getLayoutParams());
if (getWindowManager().getDefaultDisplay().getHeight() >= 800) {
marginParams_bl.setMargins((int) ((int) getWindowManager()
.getDefaultDisplay().getWidth() / 7.4),
(int) ((int) getWindowManager().getDefaultDisplay()
.getHeight() / 2.55), 0, 0);
} else if (getWindowManager().getDefaultDisplay().getHeight() == 320) {
marginParams_bl.setMargins((int) ((int) getWindowManager()
.getDefaultDisplay().getWidth() / 7.4),
(int) ((int) getWindowManager().getDefaultDisplay()
.getHeight() / 2.55), 0, 0);
} else {
marginParams_bl.setMargins((int) ((int) getWindowManager()
.getDefaultDisplay().getWidth() / 7.4),
(int) ((int) getWindowManager().getDefaultDisplay()
.getHeight() / 2.55), 0, 0);
}
RelativeLayout.LayoutParams layoutParams_bl = new RelativeLayout.LayoutParams(
marginParams_bl);
bl.setLayoutParams(layoutParams_bl);
// gujarat.setLayoutParams(new LinearLayout.LayoutParams(
// getWindowManager().getDefaultDisplay().getWidth() / 3,
// (int) (getWindowManager().getDefaultDisplay().getHeight() / 5)));
// augment.setLayoutParams(new LinearLayout.LayoutParams(
// getWindowManager().getDefaultDisplay().getWidth() / 3,
// (int) (getWindowManager().getDefaultDisplay().getHeight() / 5)));
// ff.setLayoutParams(new LinearLayout.LayoutParams(getWindowManager()
// .getDefaultDisplay().getWidth() / 3, (int) (getWindowManager()
// .getDefaultDisplay().getHeight() / 5)));
// touristspot
// .setLayoutParams(new LinearLayout.LayoutParams(
// getWindowManager().getDefaultDisplay().getWidth() / 3,
// (int) (getWindowManager().getDefaultDisplay()
// .getHeight() / 5)));
TabHost tabH = new TabHost(this);
TabWidget tabWidget = new TabWidget(this);
LinearLayout lin = new LinearLayout(this);
lin.setOrientation(LinearLayout.HORIZONTAL);
tabWidget.setId(android.R.id.tabs);
tabH.addView(tabWidget);
tabH.addView(lin);
FrameLayout fl = new FrameLayout(this);
fl.setId(android.R.id.tabcontent);

fl.setPadding(0, (int) (getWindowManager().getDefaultDisplay()
.getHeight() * 0.90), 0, 0);

lin.addView(fl);
tabH.setup();
// android.widget.TabHost.TabSpec ts1 = tabH.newTabSpec("hi");

tabH.addTab(tabH.newTabSpec("tag")

.setIndicator("").setContent(new TabHost.TabContentFactory() {
public View createTabContent(String tag) {
// -- this tab contains multiple control grouped in a panel --
// //
LinearLayout panel = new LinearLayout(
ZoomByEnterPageActivity.this);
panel.setOrientation(LinearLayout.HORIZONTAL);

panel.setBackgroundResource(R.drawable.bottom_bar);
i1 = new ImageView(ZoomByEnterPageActivity.this);
i1.setBackgroundResource(R.drawable.map_file);
i2 = new ImageView(ZoomByEnterPageActivity.this);
i2.setBackgroundResource(R.drawable.urhere_file);

i3 = new ImageView(ZoomByEnterPageActivity.this);
i3.setBackgroundResource(R.drawable.navigate_file);

i4 = new ImageView(ZoomByEnterPageActivity.this);
i4.setBackgroundResource(R.drawable.arroundme_file);

panel.addView(i1);
panel.addView(i2);
panel.addView(i3);
panel.addView(i4);

// i1.getLayoutParams().width = getWindowManager()
// .getDefaultDisplay().getWidth() / 4;
// i2.getLayoutParams().width = getWindowManager()
// .getDefaultDisplay().getWidth() / 4;
// i3.getLayoutParams().width = getWindowManager()
// .getDefaultDisplay().getWidth() / 4;
// i4.getLayoutParams().width = getWindowManager()
// .getDefaultDisplay().getWidth() / 4;

MarginLayoutParams marginParams_i1 = new MarginLayoutParams(i1
.getLayoutParams());
if (height >= 800) {
marginParams_i1.setMargins(12, 0, 12, 0);

} else if (height < 480) {
marginParams_i1.setMargins(8, 0, 8, 0);
} else {

marginParams_i1.setMargins(12, 0, 12, 0);
}
LinearLayout.LayoutParams layoutParams_i1 = new LinearLayout.LayoutParams(
marginParams_i1);
i1.setLayoutParams(layoutParams_i1);

MarginLayoutParams marginParams_i2 = new MarginLayoutParams(i2
.getLayoutParams());
if (height >= 800) {
marginParams_i2.setMargins(12, 0, 12, 0);

} else if (height < 480) {
marginParams_i2.setMargins(8, 0, 8, 0);
} else {
marginParams_i2.setMargins(12, 0, 12, 0);
}
LinearLayout.LayoutParams layoutParams_i2 = new LinearLayout.LayoutParams(
marginParams_i2);
i2.setLayoutParams(layoutParams_i2);

MarginLayoutParams marginParams_i3 = new MarginLayoutParams(i3
.getLayoutParams());
if (height >= 800) {
marginParams_i3.setMargins(12, 0, 12, 0);

} else if (height < 480) {
marginParams_i3.setMargins(8, 0, 8, 0);
} else {
marginParams_i3.setMargins(12, 0, 12, 0);
}
LinearLayout.LayoutParams layoutParams_i3 = new LinearLayout.LayoutParams(
marginParams_i3);
i3.setLayoutParams(layoutParams_i3);

MarginLayoutParams marginParams_i4 = new MarginLayoutParams(i4
.getLayoutParams());
if (height >= 800) {
marginParams_i4.setMargins(12, 0, 12, 0);
} else if (height < 480) {
marginParams_i4.setMargins(8, 0, 8, 0);
} else {
marginParams_i4.setMargins(12, 0, 12, 0);
}
LinearLayout.LayoutParams layoutParams_i4 = new LinearLayout.LayoutParams(
marginParams_i4);
i4.setLayoutParams(layoutParams_i4);
return panel;
} // TAB 1 done
}));
// ts1.setContent(new Intent(this,Tab1.class));
// tabH.addTab(ts1);
tabH.getTabWidget().getChildAt(0).getLayoutParams().height = (int) 0.000000001;
tabH.getTabWidget().getChildAt(0).getLayoutParams().width = (int) 0.0000000001;

RelativeLayout.LayoutParams tab = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

// tab.setMargins(0,(int)
// (getWindowManager().getDefaultDisplay().getHeight()*0.8) , 0, 0);
addContentView(tabH, tab);

if (getWindowManager().getDefaultDisplay().getHeight() > 800) {

// slidinglayout
// .setLayoutParams(new RelativeLayout.LayoutParams(
// (int) (getWindowManager().getDefaultDisplay()
// .getWidth()), (int) (getWindowManager()
// .getDefaultDisplay().getHeight() / 2.5)));

MarginLayoutParams marginParams_sl = new MarginLayoutParams(
slidinglayout.getLayoutParams());

marginParams_sl.setMargins(0, (int) ((int) getWindowManager()
.getDefaultDisplay().getHeight() / 2.55), 0, 0);

RelativeLayout.LayoutParams layoutParams_sl = new RelativeLayout.LayoutParams(
marginParams_sl);
slidinglayout.setLayoutParams(layoutParams_sl);

MarginLayoutParams marginParams_frnds = new MarginLayoutParams(
friends_btn.getLayoutParams());

marginParams_frnds.setMargins(0,
(int) ((height * 0.90 - (height / 2.55)) / 5.56), 0, 0);

RelativeLayout.LayoutParams layoutParams_frnds = new RelativeLayout.LayoutParams(
marginParams_frnds);
friends_btn.setLayoutParams(layoutParams_frnds);

MarginLayoutParams marginParams_close = new MarginLayoutParams(
closearrow.getLayoutParams());

marginParams_close.setMargins((int) (width / 5.89),
(int) ((height * 0.90 - (height / 2.55)) / 5.56), 0, 0);

RelativeLayout.LayoutParams layoutParams_close = new RelativeLayout.LayoutParams(
marginParams_close);
closearrow.setLayoutParams(layoutParams_close);

MarginLayoutParams marginParams_triplist = new MarginLayoutParams(
triplist_btn.getLayoutParams());

marginParams_triplist.setMargins(6, (int) ((height * 0.92
- (height / 2.55) - (height * 0.22))), 0, 0);

RelativeLayout.LayoutParams layoutParams_triplist = new RelativeLayout.LayoutParams(
marginParams_triplist);
triplist_btn.setLayoutParams(layoutParams_triplist);

} else if (height == 800) {
MarginLayoutParams marginParams_sl = new MarginLayoutParams(
slidinglayout.getLayoutParams());

marginParams_sl.setMargins(0, (int) ((int) getWindowManager()
.getDefaultDisplay().getHeight() / 2.55), 0, 0);

RelativeLayout.LayoutParams layoutParams_sl = new RelativeLayout.LayoutParams(
marginParams_sl);
slidinglayout.setLayoutParams(layoutParams_sl);

MarginLayoutParams marginParams_frnds = new MarginLayoutParams(
friends_btn.getLayoutParams());

marginParams_frnds.setMargins(0,
(int) ((height * 0.90 - (height / 2.55)) / 5), 0, 0);

RelativeLayout.LayoutParams layoutParams_frnds = new RelativeLayout.LayoutParams(
marginParams_frnds);
friends_btn.setLayoutParams(layoutParams_frnds);

MarginLayoutParams marginParams_close = new MarginLayoutParams(
closearrow.getLayoutParams());

marginParams_close.setMargins((int) (width / 5.89),
(int) ((height * 0.90 - (height / 2.55)) / 5), 0, 0);

RelativeLayout.LayoutParams layoutParams_close = new RelativeLayout.LayoutParams(
marginParams_close);
closearrow.setLayoutParams(layoutParams_close);

MarginLayoutParams marginParams_triplist = new MarginLayoutParams(
triplist_btn.getLayoutParams());

marginParams_triplist.setMargins(6, (int) ((height * 0.92
- (height / 2.55) - (height * 0.18))), 0, 0);

RelativeLayout.LayoutParams layoutParams_triplist = new RelativeLayout.LayoutParams(
marginParams_triplist);
triplist_btn.setLayoutParams(layoutParams_triplist);

} else if (getWindowManager().getDefaultDisplay().getHeight() == 320) {

MarginLayoutParams marginParams_sl = new MarginLayoutParams(
slidinglayout.getLayoutParams());

marginParams_sl.setMargins(0, (int) ((int) getWindowManager()
.getDefaultDisplay().getHeight() / 2.30), 0, 0);

RelativeLayout.LayoutParams layoutParams_sl = new RelativeLayout.LayoutParams(
marginParams_sl);
slidinglayout.setLayoutParams(layoutParams_sl);
MarginLayoutParams marginParams_frnds = new MarginLayoutParams(
friends_btn.getLayoutParams());

marginParams_frnds.setMargins(0,
(int) ((height * 0.90 - (height / 2.30)) / 6), 0, 0);

RelativeLayout.LayoutParams layoutParams_frnds = new RelativeLayout.LayoutParams(
marginParams_frnds);
friends_btn.setLayoutParams(layoutParams_frnds);

MarginLayoutParams marginParams_close = new MarginLayoutParams(
closearrow.getLayoutParams());

marginParams_close.setMargins(width / 8,
(int) ((height * 0.90 - (height / 2.30)) / 6), 0, 0);

RelativeLayout.LayoutParams layoutParams_close = new RelativeLayout.LayoutParams(
marginParams_close);
closearrow.setLayoutParams(layoutParams_close);

MarginLayoutParams marginParams_triplist = new MarginLayoutParams(
triplist_btn.getLayoutParams());

marginParams_triplist.setMargins(4, (int) (height * 0.92
- (height / 2.30) - (height * 0.175)), 0, 0);

RelativeLayout.LayoutParams layoutParams_triplist = new RelativeLayout.LayoutParams(
marginParams_triplist);
triplist_btn.setLayoutParams(layoutParams_triplist);

} else if (getWindowManager().getDefaultDisplay().getHeight() == 400) {
MarginLayoutParams marginParams_sl = new MarginLayoutParams(
slidinglayout.getLayoutParams());

marginParams_sl.setMargins(0, (int) ((int) getWindowManager()
.getDefaultDisplay().getHeight() / 2.40), 0, 0);

RelativeLayout.LayoutParams layoutParams_sl = new RelativeLayout.LayoutParams(
marginParams_sl);
slidinglayout.setLayoutParams(layoutParams_sl);
MarginLayoutParams marginParams_frnds = new MarginLayoutParams(
friends_btn.getLayoutParams());

marginParams_frnds.setMargins(0,
(int) ((height * 0.90 - (height / 2.40)) / 8), 0, 0);

RelativeLayout.LayoutParams layoutParams_frnds = new RelativeLayout.LayoutParams(
marginParams_frnds);
friends_btn.setLayoutParams(layoutParams_frnds);

MarginLayoutParams marginParams_close = new MarginLayoutParams(
closearrow.getLayoutParams());

marginParams_close.setMargins((int) (width / 8),
(int) ((height * 0.90 - (height / 2.40)) / 8), 0, 0);

RelativeLayout.LayoutParams layoutParams_close = new RelativeLayout.LayoutParams(
marginParams_close);
closearrow.setLayoutParams(layoutParams_close);

MarginLayoutParams marginParams_triplist = new MarginLayoutParams(
triplist_btn.getLayoutParams());

marginParams_triplist.setMargins(6, (int) (height * 0.92
- (height / 2.40) - (height * 0.25)), 0, 0);

RelativeLayout.LayoutParams layoutParams_triplist = new RelativeLayout.LayoutParams(
marginParams_triplist);
triplist_btn.setLayoutParams(layoutParams_triplist);

} else if (getWindowManager().getDefaultDisplay().getHeight() == 432) {
MarginLayoutParams marginParams_sl = new MarginLayoutParams(
slidinglayout.getLayoutParams());

marginParams_sl.setMargins(0, (int) ((int) getWindowManager()
.getDefaultDisplay().getHeight() / 2.40), 0, 0);

RelativeLayout.LayoutParams layoutParams_sl = new RelativeLayout.LayoutParams(
marginParams_sl);
slidinglayout.setLayoutParams(layoutParams_sl);
MarginLayoutParams marginParams_frnds = new MarginLayoutParams(
friends_btn.getLayoutParams());

marginParams_frnds.setMargins(0,
(int) ((height * 0.90 - (height / 2.40)) / 9), 0, 0);

RelativeLayout.LayoutParams layoutParams_frnds = new RelativeLayout.LayoutParams(
marginParams_frnds);
friends_btn.setLayoutParams(layoutParams_frnds);

MarginLayoutParams marginParams_close = new MarginLayoutParams(
closearrow.getLayoutParams());

marginParams_close.setMargins((int) (width / 8),
(int) ((height * 0.90 - (height / 2.40)) / 9), 0, 0);

RelativeLayout.LayoutParams layoutParams_close = new RelativeLayout.LayoutParams(
marginParams_close);
closearrow.setLayoutParams(layoutParams_close);

MarginLayoutParams marginParams_triplist = new MarginLayoutParams(
triplist_btn.getLayoutParams());

marginParams_triplist.setMargins(6, (int) (height * 0.92
- (height / 2.40) - (height * 0.265)), 0, 0);

RelativeLayout.LayoutParams layoutParams_triplist = new RelativeLayout.LayoutParams(
marginParams_triplist);
triplist_btn.setLayoutParams(layoutParams_triplist);

}

else {
MarginLayoutParams marginParams_sl = new MarginLayoutParams(
slidinglayout.getLayoutParams());

marginParams_sl.setMargins(0, (int) ((int) getWindowManager()
.getDefaultDisplay().getHeight() / 2.40), 0, 0);

RelativeLayout.LayoutParams layoutParams_sl = new RelativeLayout.LayoutParams(
marginParams_sl);
slidinglayout.setLayoutParams(layoutParams_sl);
MarginLayoutParams marginParams_frnds = new MarginLayoutParams(
friends_btn.getLayoutParams());

marginParams_frnds.setMargins(0,
(int) ((height * 0.90 - (height / 2.40)) / 5.5), 0, 0);

RelativeLayout.LayoutParams layoutParams_frnds = new RelativeLayout.LayoutParams(
marginParams_frnds);
friends_btn.setLayoutParams(layoutParams_frnds);

MarginLayoutParams marginParams_close = new MarginLayoutParams(
closearrow.getLayoutParams());

marginParams_close.setMargins((int) (width / 8),
(int) ((height * 0.90 - (height / 2.40)) / 5.5), 0, 0);

RelativeLayout.LayoutParams layoutParams_close = new RelativeLayout.LayoutParams(
marginParams_close);
closearrow.setLayoutParams(layoutParams_close);

MarginLayoutParams marginParams_triplist = new MarginLayoutParams(
triplist_btn.getLayoutParams());

marginParams_triplist.setMargins(6, (int) (height * 0.92
- (height / 2.40) - (height * 0.20)), 0, 0);

RelativeLayout.LayoutParams layoutParams_triplist = new RelativeLayout.LayoutParams(
marginParams_triplist);
triplist_btn.setLayoutParams(layoutParams_triplist);

}
slidingpanel.setBackgroundResource(R.drawable.sidepanel_bg);
// updateUI();
open.setOnClickListener(new OnClickListener() {
public void onClick(View v) {

slidingpanel.setVisibility(View.VISIBLE);

open.setVisibility(View.INVISIBLE);
}
});
settings.setOnClickListener(new OnClickListener() {
public void onClick(View v) {

Intent intent = new Intent(ZoomByEnterPageActivity.this,
SettingsActivity.class);
intent.putExtra("u_id", u_id);
startActivity(intent);

}
});
ff.setOnClickListener(new OnClickListener() {
public void onClick(View v) {

Intent intent = new Intent(ZoomByEnterPageActivity.this,
FandFActivity.class);
intent.putExtra("u_id", u_id);
intent.putExtra("no", "5");
startActivity(intent);

}
});
touristspot.setOnClickListener(new OnClickListener() {
public void onClick(View v) {

Intent intent = new Intent(ZoomByEnterPageActivity.this,
MainListActivity.class);
intent.putExtra("u_id", u_id);
intent.putExtra("no", "4");
startActivity(intent);

}
});

closearrow.setOnClickListener(new OnClickListener() {
public void onClick(View v) {

slidingpanel.setVisibility(View.INVISIBLE);

open.setVisibility(View.VISIBLE);

}
});

i1.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent = new Intent(ZoomByEnterPageActivity.this,
Map.class);

startActivity(intent);
}
});

i2.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent = new Intent(ZoomByEnterPageActivity.this,
Mapper.class);

startActivity(intent);
}
});
i3.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent = new Intent(ZoomByEnterPageActivity.this,
navigateAllActivity.class);

startActivity(intent);
}
});
i4.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent = new Intent(ZoomByEnterPageActivity.this,
AroundmeActivity.class);

startActivity(intent);
}
});

augment.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent = new Intent(ZoomByEnterPageActivity.this,
ImageTargets.class);

startActivity(intent);
}
});
wishlist_btn.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent = new Intent(ZoomByEnterPageActivity.this,
WishlistActivity.class);
intent.putExtra("u_id", u_id);
startActivity(intent);
}
});

gujarat.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// do whatever you need
Intent intent = new Intent(ZoomByEnterPageActivity.this,
ProfileActivity.class);
intent.putExtra("u_id", u_id);
startActivity(intent);
}
});
fetchData.start();

}

/*
* public void updateUI() { int currentInt = 10; if (currentInt <= 100) {
* refreshHandler.sleep(2000);
*
* if (i < imgid.length) { slideshow.setImageResource(imgid[i]); currentInt
* = currentInt + 10; // imageView.setPadding(left, top, right, bottom);
* i++; } } }
*/

/*
* class RefreshHandler extends Handler {
*
* @Override public void handleMessage(Message msg) { // TODO Auto-generated
* method stub ZoomByEnterPageActivity.this.updateUI(); }
*
* public void sleep(long delayMillis) { this.removeMessages(0);
* sendMessageDelayed(obtainMessage(0), delayMillis); } }
*/

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if (arg0.getId() == R.id.mainlayout) {
slidingpanel.setVisibility(View.INVISIBLE);

open.setVisibility(View.VISIBLE);
}

}

final Handler handler = new Handler() {
public void handleMessage(Message msg) {
try {
// int start = responseBody.indexOf("{");
// int end = responseBody.length();
// String result = responseBody.substring(start, end);
// // Toast.makeText(getApplicationContext(), result,
// 9000).show();

int start = responseBody.indexOf("status");
int end = responseBody.length();
String result = responseBody.substring(start, end);
String result1 = "[{" + '"' + result.toString().trim();
// Toast.makeText(getApplicationContext(), result1,
// 9000).show();
// Log.e("result", "" + result1);

try {
jArray = new JSONArray(result1.toString());
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}

try {
items = new String[jArray.length()];

for (int i = 0; i < jArray.length(); i++) {

items[i] = jArray.getJSONObject(i).getString("status")
.toString();
slide = jArray.getJSONObject(i).getString("slide")
.toString();
}
jSubArray = new JSONArray(slide.toString());

path = new String[jSubArray.length()];
id = new String[jSubArray.length()];
Id = new int[jSubArray.length()];

// Toast.makeText(getApplicationContext(),
// jSubArray.toString(), 6000).show();

for (int j = 0; j < jSubArray.length(); j++) {
path[j] = jSubArray.getJSONObject(j).getString("path")
.toString();
id[j] = jSubArray.getJSONObject(j).getString("id")
.toString();
Id[j] = Integer.parseInt(id[j]);
// Toast.makeText(getApplicationContext(), "" +
// thumb[j],
// 7000).show();
total = jSubArray.length();
}

} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
if (items[0].equalsIgnoreCase("OK")) {
if ((dialog.isShowing()))
dialog.dismiss();

} else {
if ((dialog.isShowing()))
dialog.dismiss();
Toast.makeText(getApplicationContext(),
"try after some time", 4000).show();
}
} catch (NullPointerException e) {
if ((dialog.isShowing()))
dialog.dismiss();
Toast.makeText(getApplicationContext(), "try after some time",
4000).show();
}

// categories = new ImageView[total];
// for (int i = 0; i < total; i++) {
//
// categories[i] = new ImageView(ZoomByEnterPageActivity.this);
//
// categories[i].setId(i);
// detaillayout.addView(categories[i], layout_button);
//
// }
//
// for (int j = 0; j < total; j++) {
// // categories[j].setText(name[j]);
// }
// /////////////////////////////////////////////////
try {
int start_tspot = responseBody_tspot.indexOf("status");
int end_tspot = responseBody_tspot.length();
String result_tspot = responseBody_tspot.substring(start_tspot,
end_tspot);
String result1_tspot = "[{" + '"'
+ result_tspot.toString().trim();
// Toast.makeText(getApplicationContext(), result1,
// 9000).show();
// Log.e("result", "" + result1);

try {
jArray = new JSONArray(result1_tspot.toString());
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}

try {
items_tspot = new String[jArray.length()];

for (int i = 0; i < jArray.length(); i++) {

items_tspot[i] = jArray.getJSONObject(i)
.getString("status").toString();
info_tspot = jArray.getJSONObject(i).getString("info")
.toString();
}
jSubArray = new JSONArray(info_tspot.toString());

spot_id_tspot = new String[jSubArray.length()];
cat_id_tspot = new String[jSubArray.length()];
name_tspot = new String[jSubArray.length()];
cat_tspot = new String[jSubArray.length()];
one_liner_tspot = new String[jSubArray.length()];
thumb_tspot = new String[jSubArray.length()];
// Toast.makeText(getApplicationContext(),
// jSubArray.toString(), 6000).show();

for (int j = 0; j < jSubArray.length(); j++) {
spot_id_tspot[j] = jSubArray.getJSONObject(j)
.getString("spot_id").toString().trim();
name_tspot[j] = jSubArray.getJSONObject(j)
.getString("name").toString().trim();
cat_tspot[j] = jSubArray.getJSONObject(j)
.getString("cat").toString().trim();
one_liner_tspot[j] = jSubArray.getJSONObject(j)
.getString("one_liner").toString().trim();
thumb_tspot[j] = jSubArray.getJSONObject(j)
.getString("thumb").toString().trim();
cat_id_tspot[j] = jSubArray.getJSONObject(j)
.getString("cat_id").toString().trim();

total_tspot = jSubArray.length();
}

} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
if (items[0].equalsIgnoreCase("OK")) {
if ((dialog.isShowing()))
dialog.dismiss();

} else {
if ((dialog.isShowing()))
dialog.dismiss();
Toast.makeText(getApplicationContext(),
"try after some time", 4000).show();
}
} catch (NullPointerException e) {
if ((dialog.isShowing()))
dialog.dismiss();
Toast.makeText(getApplicationContext(), "try after some time",
4000).show();
}

listview.setAdapter(new mAdapter(ZoomByEnterPageActivity.this));

if ((dialog.isShowing()))
dialog.dismiss();

/*
* try {
*
* Activity activity; String[] data;
*
* activity = ZoomByEnterPageActivity.this; data = path; inflater =
* (LayoutInflater) activity
* .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
*
* imageLoader = new ImageLoader1(activity.getApplicationContext());
*
* for (int i = 0; i < total; i++) {
*
* // imageview_left[i].setImageBitmap(bmp[i]);
* categories[i].setTag(data[i]);
*
* imageLoader.DisplayImage(data[i], activity, categories[i]);
*
* } } catch (NullPointerException f) {
* Toast.makeText(getApplicationContext(), "reload the page", 5000)
* .show(); } catch (ArrayIndexOutOfBoundsException g) {
* Toast.makeText(getApplicationContext(), "reload the page", 5000)
* .show(); }
*/

}
};

Thread fetchData = new Thread() {// worker thread or background thread
public void run() {

double TIMEOUT_MILLISEC = 1234567890;

HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams,
(int) TIMEOUT_MILLISEC);
HttpConnectionParams.setSoTimeout(httpParams,
(int) TIMEOUT_MILLISEC);
//
HttpParams p = new BasicHttpParams();
// p.setParameter("name", pvo.getName());

p.setParameter("View slideshow", "View slideshow");

p.setParameter("key", "c89a7662dae613ea3d20d334339b6dff");

// Instantiate an HttpClient
HttpClient httpclient = new DefaultHttpClient(p);

HttpPost httppost = new HttpPost(URL);

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);

nameValuePairs.add(new BasicNameValuePair("View slideshow",
"View slideshow"));
nameValuePairs.add(new BasicNameValuePair("key",
"c89a7662dae613ea3d20d334339b6dff"));

try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e) { // TODO Auto-generated
// catch
;
}

ResponseHandler<String> responseHandler = new BasicResponseHandler();
try {
responseBody = httpclient.execute(httppost, responseHandler);
Log.e("aaaaaaaaaaaaaaaaaaaaaaaaa+++", responseBody.toString());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// ///////////////////
HttpParams httpParams_tspot = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams_tspot,
(int) TIMEOUT_MILLISEC);
HttpConnectionParams.setSoTimeout(httpParams_tspot,
(int) TIMEOUT_MILLISEC);
//
HttpParams p_tspot = new BasicHttpParams();
// p.setParameter("name", pvo.getName());

p_tspot.setParameter("Get List", "Get List");
p_tspot.setParameter("type", "4");

p_tspot.setParameter("key", "c89a7662dae613ea3d20d334339b6dff");

// Instantiate an HttpClient
HttpClient httpclient_tspot = new DefaultHttpClient(p_tspot);

HttpPost httppost_tspot = new HttpPost(URL_tspot);

List<NameValuePair> nameValuePairs_tspot = new ArrayList<NameValuePair>(
3);

nameValuePairs_tspot.add(new BasicNameValuePair("Get List",
"Get List"));
nameValuePairs_tspot.add(new BasicNameValuePair("key",
"c89a7662dae613ea3d20d334339b6dff"));
nameValuePairs_tspot.add(new BasicNameValuePair("type", "4"));

try {
httppost_tspot.setEntity(new UrlEncodedFormEntity(
nameValuePairs_tspot));
} catch (UnsupportedEncodingException e) { // TODO Auto-generated
// catch
;
}

ResponseHandler<String> responseHandler_tspot = new BasicResponseHandler();
try {
responseBody_tspot = httpclient_tspot.execute(httppost_tspot,
responseHandler_tspot);
Log.e("aaaaaaaaaaaaaaaaaaaaaaaaa+++",
responseBody_tspot.toString());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

handler.sendEmptyMessage(0);
}

};

// public boolean onContextItemSelected(MenuItem item) {
// AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
// .getMenuInfo(); switch (item.getItemId()) { default:
// return true;
//
// default: // return super.onContextItemSelected(item); } }

// public View makeView() {
// ImageView iView = new ImageView(this);
// iView.setScaleType(ImageView.ScaleType.FIT_CENTER);
// iView.setLayoutParams(new ImageSwitcher.LayoutParams(
// LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
// iView.setBackgroundColor(0xFF000000);
// return iView;
// }

private class mAdapter extends BaseAdapter {

@Override
public int getCount() {
return DATA.length;
}

public class ViewHolder {
public ImageView Image;
}

public mAdapter(Context c) {
mContext = c;
imageLoader = new ImageLoader1(
ZoomByEnterPageActivity.this.getApplicationContext());
}

@Override
public Object getItem(int position) {
return null;
}

@Override
public long getItemId(int position) {
return 0;
}

@Override
public View getView(final int position, View convertView,
ViewGroup parent) {
// View retval = LayoutInflater.from(parent.getContext()).inflate(
// R.layout.horizontallistview, null);
ViewHolder holder;
View v = convertView;

if (convertView == null) {
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.horizontallistview, null, true);
holder = new ViewHolder();

holder.Image = (ImageView) v.findViewById(R.id.iv);

v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}

holder.Image.setTag(path[position]);
holder.Image.getLayoutParams().height = (int) (height / 4);
holder.Image.getLayoutParams().width = width / 4;
imageLoader.DisplayImage(path[position],
ZoomByEnterPageActivity.this, holder.Image);
holder.Image.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {
int j = -1;
String[] name_temp = new String[total_tspot + 1];
String[] one_liner_temp = new String[total_tspot + 1];
String[] thumb_temp = new String[total_tspot + 1];
String[] spot_id_temp = new String[total_tspot + 1];

for (int y = 0; y < total_tspot; y++) {
if (Id[position] == Integer.parseInt(cat_id_tspot[y])) {
j++;
name_temp[j] = name_tspot[y];
one_liner_temp[j] = one_liner_tspot[y];
thumb_temp[j] = thumb_tspot[y];
spot_id_temp[j] = spot_id_tspot[y];

} else {
continue;
}
}

Intent intent = new Intent(ZoomByEnterPageActivity.this,
FilteredActivity.class);

Bundle b = new Bundle();

b.putStringArray("thumb", thumb_temp);
b.putStringArray("one_liner", one_liner_temp);
b.putStringArray("name", name_temp);
b.putStringArray("mainspot_id", spot_id_temp);
b.putInt("total", j + 1);
b.putString("kind", "spot");

intent.putExtras(b);

ZoomByEnterPageActivity.this.finish();

startActivity(intent);

}
});

return v;
}

private Context mContext;
Integer[] DATA = new Integer[total];
{
for (int o = 0; o < total; o++) {
DATA[o] = R.drawable.icon_vuforia;
}
}

};

}

No comments:

Post a Comment