Android Open Source - reflect-app Stackoverview From Project Back to project page reflect-app .
License The source code is released under:
Apache License
If you think the Android project reflect-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package com.pontydysgu.pontylearningapp;
/ * f r o m w w w . j a v a 2 s . c o m * /
import com.example.pontylearningapp.R;
import com.pontydysgu.data.LoginData;
import com.pontydysgu.data.QuestionStack;
import com.pontydysgu.data.StackArray;
import com.pontydysgu.gui.StackArrayAdapter;
import com.pontydysgu.webio.RetrieveStacksTask;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
import com.pontydysgu.webio.*;
public class Stackoverview extends Activity implements RetrieveStacksCallback {
public static final String PREFS_NAME = "PontydysguLearningApp" ;
public static final String PREF_TMPUSERNAME = "TMPPontyUser" ;
public static final String PREF_TMPPASSWORD = "TMPPontyPass" ;
private LoginData logindata;
private ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stackoverview);
// Restore preferences
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
String username = settings.getString(PREF_TMPUSERNAME, "" );
String password = settings.getString(PREF_TMPPASSWORD, "" );
logindata = new LoginData();
logindata.setPassword(password);
logindata.setUsername(username);
//this.setTitle("Ponty Learning App");
this.listView = (ListView) this.findViewById(R.id.listView);
this.listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position,
long id) {
StackArrayAdapter adapter = (StackArrayAdapter) adapterView.getAdapter();
QuestionStack item = adapter.getItem(position);
if (item.getQuestions() != null && item.getQuestions().size() > 0) {
onStackClicked(item);
} else {
Toast.makeText(Stackoverview.this, "There are no questions in the stack!" , Toast.LENGTH_LONG).show();
}
}
});
// Start retrieve stacks task in background
RetrieveStacksTask getStacks = new RetrieveStacksTask(this , this.logindata);
getStacks.execute();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.stackoverview, menu);
return true;
}
protected void onStackClicked(QuestionStack item) {
Intent intent = new Intent(this , QuestionCycle.class);
intent.putExtra("stackId" , item.getId());
startActivity(intent);
}
@Override
public void onStacksRecieved(StackArray stackArray) {
DataService.getInstance().setStackArray(stackArray);
// this.listView.set
//Log.i(TAG, "Recieved Stacklist: "+stackArray);
StackArrayAdapter listAdapter = new StackArrayAdapter(stackArray, this , android.R.layout.simple_list_item_1);
this.listView.setAdapter(listAdapter);
}
}
Java Source Code List com.google.gson.DefaultDateTypeAdapter.java com.google.gson.ExclusionStrategy.java com.google.gson.FieldAttributes.java com.google.gson.FieldNamingPolicy.java com.google.gson.FieldNamingStrategy.java com.google.gson.GsonBuilder.java com.google.gson.Gson.java com.google.gson.InstanceCreator.java com.google.gson.JsonArray.java com.google.gson.JsonDeserializationContext.java com.google.gson.JsonDeserializer.java com.google.gson.JsonElement.java com.google.gson.JsonIOException.java com.google.gson.JsonNull.java com.google.gson.JsonObject.java com.google.gson.JsonParseException.java com.google.gson.JsonParser.java com.google.gson.JsonPrimitive.java com.google.gson.JsonSerializationContext.java com.google.gson.JsonSerializer.java com.google.gson.JsonStreamParser.java com.google.gson.JsonSyntaxException.java com.google.gson.LongSerializationPolicy.java com.google.gson.TreeTypeAdapter.java com.google.gson.TypeAdapterFactory.java com.google.gson.TypeAdapter.java com.google.gson.annotations.Expose.java com.google.gson.annotations.SerializedName.java com.google.gson.annotations.Since.java com.google.gson.annotations.Until.java com.google.gson.annotations.package-info.java com.google.gson.internal.ConstructorConstructor.java com.google.gson.internal.Excluder.java com.google.gson.internal.JsonReaderInternalAccess.java com.google.gson.internal.LazilyParsedNumber.java com.google.gson.internal.LinkedHashTreeMap.java com.google.gson.internal.ObjectConstructor.java com.google.gson.internal.Primitives.java com.google.gson.internal.Streams.java com.google.gson.internal.UnsafeAllocator.java com.google.gson.internal.$Gson$Preconditions.java com.google.gson.internal.$Gson$Types.java com.google.gson.internal.bind.ArrayTypeAdapter.java com.google.gson.internal.bind.CollectionTypeAdapterFactory.java com.google.gson.internal.bind.DateTypeAdapter.java com.google.gson.internal.bind.JsonTreeReader.java com.google.gson.internal.bind.JsonTreeWriter.java com.google.gson.internal.bind.MapTypeAdapterFactory.java com.google.gson.internal.bind.ObjectTypeAdapter.java com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.java com.google.gson.internal.bind.SqlDateTypeAdapter.java com.google.gson.internal.bind.TimeTypeAdapter.java com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.java com.google.gson.internal.bind.TypeAdapters.java com.google.gson.internal.package-info.java com.google.gson.reflect.TypeToken.java com.google.gson.reflect.package-info.java com.google.gson.stream.JsonReader.java com.google.gson.stream.JsonScope.java com.google.gson.stream.JsonToken.java com.google.gson.stream.JsonWriter.java com.google.gson.stream.MalformedJsonException.java com.google.gson.package-info.java com.pontydysgu.data.Answer.java com.pontydysgu.data.LoginData.java com.pontydysgu.data.QuestionStack.java com.pontydysgu.data.Question.java com.pontydysgu.data.StackArray.java com.pontydysgu.gui.StackArrayAdapter.java com.pontydysgu.pontylearningapp.DataService.java com.pontydysgu.pontylearningapp.Login.java com.pontydysgu.pontylearningapp.QuestionCycle.java com.pontydysgu.pontylearningapp.Stackoverview.java com.pontydysgu.webio.GetWebRequest.java com.pontydysgu.webio.LoginService.java com.pontydysgu.webio.PontyService.java com.pontydysgu.webio.RetrieveStacksCallback.java com.pontydysgu.webio.RetrieveStacksTask.java com.pontydysgu.webio.SubmitAnswerCallback.java com.pontydysgu.webio.SubmitAnswerTask.java