Skip to content

Commit

Permalink
Doc page now works. Added skel for list adapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
kcunning committed Sep 18, 2011
1 parent 8ca17a2 commit 72c6ae5
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 40 deletions.
Binary file modified branches/django-android-0.9/Django Explorer/bin/Django Explorer.apk
Binary file not shown.
Binary file modified branches/django-android-0.9/Django Explorer/bin/classes.dex
Binary file not shown.
Binary file modified branches/django-android-0.9/Django Explorer/bin/resources.ap_
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
>
<TextView
android:background="#ffffff"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/class_title">

</TextView>
<TextView
android:layout_width="fill_parent"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public String getModuleDescription(String parent_id) {
}

public Cursor getClasses(String parent_id) {
String query = "select title from classes where parent_id = " + parent_id;
String query = "select title, desc from classes where parent_id = " + parent_id;

Cursor result = myDataBase.rawQuery(query, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

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

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
Expand All @@ -17,6 +20,7 @@ public class Module extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
System.out.println("In Module");
super.onCreate(savedInstanceState);
setContentView(R.layout.module);

Expand All @@ -28,7 +32,6 @@ public void onCreate(Bundle savedInstanceState) {
String title = extras.getString("title");
String parent_id = extras.getString("parent_id");


TextView titleView = (TextView) findViewById(R.id.title);
titleView.setText(title);

Expand All @@ -39,18 +42,21 @@ public void onCreate(Bundle savedInstanceState) {
Cursor classesCursor;
classesCursor = myDbHelper.getClasses(parent_id);

List <String> classes = new ArrayList();
ArrayList <ModuleClass> classes = new ArrayList();
if (classesCursor.moveToFirst()) {
do {
classes.add(classesCursor.getString(0));
ModuleClass mod = new ModuleClass();
mod.setTitle(classesCursor.getString(0));
mod.setDescription(classesCursor.getString(1));
classes.add(mod);

} while (classesCursor.moveToNext());
}

ListView classesView = (ListView) findViewById(R.id.classes);
ArrayAdapter<String> classesAdapter;


classesView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, classes));
ModuleAdapter adapter = new ModuleAdapter(this, R.layout.list_with_desc, classes);
classesView.setAdapter(adapter);


}
Expand All @@ -70,5 +76,37 @@ public void getDb() {
throw sqle;
}

}

public class ModuleAdapter extends ArrayAdapter<ModuleClass> {

private ArrayList<ModuleClass> items;

public ModuleAdapter(Context context, int textViewResourceId, ArrayList<ModuleClass> items) {
super(context, textViewResourceId);
this.items = items;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
System.out.println("In getView");
View v = convertView;

LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.list_with_desc, null);

ModuleClass mod = items.get(position);

System.out.println("There's a mod");
TextView titleView = (TextView) v.findViewById(R.id.class_title);
TextView descView = (TextView) v.findViewById(R.id.class_desc);
titleView.setText(mod.getTitle());
System.out.println(mod.getTitle());
descView.setText(mod.getDesc());

return v;
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ public String getDesc() {
public void setTitle(String newTitle) {
this.title = newTitle;
}

public void setDescription(String desc) {
this.desc = desc;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void onCreate(Bundle savedInstanceState) {

getDb(); //Creates a connection to the database which can be used for queries

String title;
final String title;

Bundle extras = getIntent().getExtras();

Expand All @@ -51,13 +51,23 @@ public void onCreate(Bundle savedInstanceState) {
parent = "0";
} else {
parent = (String) extras.get("parent_id");

title = (String) extras.get("title");
}
Button docButton = (Button) findViewById(R.id.docs);

if (parent == "0" || !packagesWithModules.contains(parent)) {
docButton.setVisibility(View.GONE);
} else {
docButton.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
Intent intent = new Intent(v.getContext(), Module.class);
intent.putExtra("parent_id", parent);
intent.putExtra("title", title);
startActivityForResult(intent, 0);

}
});
}

TextView titleView = (TextView) findViewById(R.id.title);
Expand Down

0 comments on commit 72c6ae5

Please sign in to comment.