Created
October 28, 2013 18:21
-
-
Save ajamaica/7201890 to your computer and use it in GitHub Desktop.
lista con parse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
*/ | |
package mx.com.estrategiatec.TDU; | |
import android.content.Intent; | |
import android.content.SharedPreferences; | |
import android.graphics.PixelFormat; | |
import android.os.Bundle; | |
import android.preference.PreferenceManager; | |
import android.support.v4.app.FragmentActivity; | |
import android.util.Log; | |
import android.view.View; | |
import android.view.Window; | |
import android.widget.AdapterView; | |
import android.widget.LinearLayout; | |
import android.widget.ListView; | |
import com.parse.FindCallback; | |
import com.parse.ParseException; | |
import com.parse.ParseObject; | |
import com.parse.ParseQuery; | |
import mx.com.estrategiatec.TDU.Adapters.HotDealsAdapter; | |
import mx.com.estrategiatec.TDU.HotDeals.HotdDeal; | |
import java.util.List; | |
/** | |
* @author Castro This class is the activity that manages the user's favorite | |
* venues | |
*/ | |
public class HotDealsController extends FragmentActivity { | |
// @Override | |
// public void onAttachedToWindow() { | |
// super.onAttachedToWindow(); | |
// Window window = getWindow(); | |
// window.setFormat(PixelFormat.RGBA_8888); | |
// } | |
private ListView lista; | |
private ParseObject[] data; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
Window window = getWindow(); | |
window.setFormat(PixelFormat.RGBA_8888); | |
setContentView(R.layout.hot_deals_controller); | |
SharedPreferences prefs = PreferenceManager | |
.getDefaultSharedPreferences(HotDealsController.this); | |
String raw = prefs.getString( | |
HotDealsController.this.getString(R.string.lpref_region_key), null); | |
final String[] regions = PreferenceListMultiSelect | |
.parseStoredValue(raw); | |
for (String region : regions) { | |
Log.d("mx.com.estrategiatec.TDU.TDU", region); | |
} | |
ParseQuery<ParseObject> query = ParseQuery.getQuery("HotDeals"); | |
query.whereEqualTo("Activo",true); | |
query.findInBackground(new FindCallback<ParseObject>() { | |
public void done(List<ParseObject> objects, ParseException e) { | |
if (e == null) { | |
LinearLayout l = (LinearLayout) findViewById(R.id.cargandobar_list1); | |
l.setVisibility(View.GONE); | |
data = objects.toArray(new ParseObject[objects.size()]); | |
HotDealsAdapter adapter2 = new HotDealsAdapter(HotDealsController.this, R.layout.hotdeal, data); | |
lista = (ListView) findViewById(R.id.listView); | |
lista.setAdapter(adapter2); | |
lista.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |
@Override | |
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { | |
TDU app = (TDU) getApplication(); | |
app.hotdeal = data[i]; | |
Intent intent = new Intent(HotDealsController.this,HotdDeal.class); | |
startActivity(intent); | |
} | |
}); | |
} else { | |
} | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment