Skip to content

Commit

Permalink
fake odjava od izpita
Browse files Browse the repository at this point in the history
  • Loading branch information
majcn committed Apr 17, 2012
1 parent 64b6d0c commit 9af2209
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 6 deletions.
12 changes: 12 additions & 0 deletions estudentAndroid/res/layout/exams_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_login">

<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

</LinearLayout>
File renamed without changes.
1 change: 0 additions & 1 deletion estudentAndroid/res/layout/menu_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/background_login">

<ListView
Expand Down
40 changes: 40 additions & 0 deletions estudentAndroid/res/layout/menu_row.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip" >

<ImageView
android:id="@+id/menu_row_image"
android:layout_width="64dp"
android:layout_height="64dp"
android:scaleType="fitXY"
android:layout_marginRight="6dip"
android:contentDescription="@string/menu_item_picture"
android:src="@drawable/ic_launcher" />

<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >

<TextView
android:id="@+id/toptext"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center_vertical"
android:textColor="@color/black" />

<TextView
android:id="@+id/bottomtext"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:ellipsize="marquee"
android:singleLine="true"
android:textColor="@color/black" />
</LinearLayout>

</LinearLayout>
3 changes: 3 additions & 0 deletions estudentAndroid/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<string name="applied_exams">Seznam prijavljanih izpitov</string>
<string name="menu_no_items">nimamo se nic za pokazati</string>

<!-- oznake za menu izpitov -->
<string name="unapply">Odjava</string>

<!-- opisi slik -->

<string name="menu_item_picture">slika</string>
Expand Down
29 changes: 26 additions & 3 deletions estudentAndroid/src/org/psywerx/estudent/AppliedExamsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class AppliedExamsActivity extends ListActivity {

private ProgressDialog m_ProgressDialog = null;
private ArrayList<MenuItem> m_orders = null;
private OrderAdapter m_adapter;
private Runnable viewOrders;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_layout);
m_orders = new ArrayList<MenuItem>();
this.m_adapter = new OrderAdapter(this, R.layout.row, m_orders);
this.m_adapter = new OrderAdapter(this, R.layout.exams_row, m_orders);
setListAdapter(this.m_adapter);

registerForContextMenu(getListView());

viewOrders = new Runnable(){
public void run() {
Expand All @@ -38,6 +44,21 @@ public void run() {
m_ProgressDialog = ProgressDialog.show(AppliedExamsActivity.this,
"Please wait...", "Retrieving data ...", true);
}

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(R.string.unapply);
}

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
Toast.makeText(this, "Odjava od izpita "+info.position, Toast.LENGTH_SHORT).show();
return super.onContextItemSelected(item);
}

private Runnable returnRes = new Runnable() {
public void run() {
if(m_orders != null && m_orders.size() > 0){
Expand All @@ -49,6 +70,7 @@ public void run() {
m_adapter.notifyDataSetChanged();
}
};

private void getExamsList(){
try{
m_orders = new ArrayList<MenuItem>();
Expand All @@ -67,6 +89,7 @@ private void getExamsList(){
}
runOnUiThread(returnRes);
}

private class OrderAdapter extends ArrayAdapter<MenuItem> {

private ArrayList<MenuItem> items;
Expand All @@ -80,7 +103,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
v = vi.inflate(R.layout.exams_row, null);
}
MenuItem o = items.get(position);
if (o != null) {
Expand Down
4 changes: 2 additions & 2 deletions estudentAndroid/src/org/psywerx/estudent/MenuActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_layout);
mMenuItemsList = new ArrayList<MenuItem>();
this.mMenuAdapter = new MenuAdapter(this, R.layout.row, mMenuItemsList);
this.mMenuAdapter = new MenuAdapter(this, R.layout.menu_row, mMenuItemsList);
setListAdapter(this.mMenuAdapter);

getDataFromParent();
Expand Down Expand Up @@ -114,7 +114,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
v = vi.inflate(R.layout.menu_row, null);
}
MenuItem o = items.get(position);
if (o != null) {
Expand Down

0 comments on commit 9af2209

Please sign in to comment.