Commit 0161f043 by Kunj Gupta

UOFLMA-26: Catalog items page is created.

parent 04189a83
......@@ -71,7 +71,14 @@ public class CatalogueCategoryAdapter extends BaseAdapter {
Catalogue catalogue = mCatalogueList.get(position);
holder.titleTextView.setText(catalogue.getTitle());
holder.desTextView.setText(catalogue.getDescription());
if(!catalogue.getDescription().isEmpty()) {
holder.desTextView.setVisibility(View.VISIBLE);
holder.desTextView.setText(catalogue.getDescription());
} else {
holder.desTextView.setVisibility(View.GONE);
holder.desTextView.setText(catalogue.getDescription());
}
return convertView;
}
......
......@@ -28,10 +28,10 @@ public class CatalogueCategoryItemAdapter extends BaseAdapter {
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void setCatalogueList(List<CatalogueItem> catalogueList) {
public void setCatalogueItemList(List<CatalogueItem> catalogueItemList) {
mCatalogueItemList.clear();
if(catalogueList!=null)
mCatalogueItemList.addAll(catalogueList);
if(catalogueItemList!=null)
mCatalogueItemList.addAll(catalogueItemList);
notifyDataSetChanged();
}
......@@ -71,7 +71,13 @@ public class CatalogueCategoryItemAdapter extends BaseAdapter {
CatalogueItem catalogueItem = mCatalogueItemList.get(position);
holder.nameTextView.setText(catalogueItem.getName());
holder.desTextView.setText(catalogueItem.getShortDescription());
if(!catalogueItem.getShortDescription().isEmpty()) {
holder.desTextView.setVisibility(View.VISIBLE);
holder.desTextView.setText(catalogueItem.getShortDescription());
} else {
holder.desTextView.setVisibility(View.GONE);
holder.desTextView.setText(catalogueItem.getShortDescription());
}
return convertView;
}
......
package com.vsoft.uofl_catalogue.ui;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.view.Gravity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
......@@ -25,12 +27,19 @@ import com.vsoft.uofl_catalogue.utils.Constants;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Created by Kunj on 11/8/16.
*/
public class CatalogueItemScreen extends Activity {
public class CatalogueItemScreen extends AppCompatActivity {
@BindView(R.id.tool_bar_view) Toolbar mToolbar;
@BindView(R.id.catalogue_item_screen_list_view) ListView mListView;
@BindView(R.id.catalogue_item_screen_empty_text_view) TextView mEmptyTextView;
private String mCatalogueSysId;
private String mCatalogueSysId, mCatalogueTitle;
private List<CatalogueItem> mCatalogueItemList;
private CatalogueApplication mApplication;
......@@ -39,12 +48,25 @@ public class CatalogueItemScreen extends Activity {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.catalogue_item_screen);
ButterKnife.bind(this);
mApplication = (CatalogueApplication) getApplication();
mCatalogueSysId = getIntent().getExtras().getString(Constants.DATA_KEY_SYS_ID);
mCatalogueTitle = getIntent().getExtras().getString(Constants.DATA_KEY_CATALOGUE_TITLE);
Bundle extras = getIntent().getExtras();
if (extras != null) {
mCatalogueSysId = extras.getString(Constants.DATA_KEY_SYS_ID);
//The key argument here must match that used in the other activity
if (mCatalogueSysId == null) {
CatalogueLog.e("CatalogueItemScreen: mCatalogueSysId is null");
}
setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setElevation(0);
actionBar.setTitle(mCatalogueTitle);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
}
if(mApplication.isNetConnected()) {
......@@ -95,40 +117,43 @@ public class CatalogueItemScreen extends Activity {
progressDialog.dismiss();
}
if(mCatalogueItemList!=null) {
createView(mCatalogueItemList);
setData();
}
}
}
private void createView(final List<CatalogueItem> catalogueItemList) {
if(!catalogueItemList.isEmpty()) {
ListView listView = new ListView(CatalogueItemScreen.this);
private void setData() {
if(!mCatalogueItemList.isEmpty()) {
mListView.setVisibility(View.VISIBLE);
mEmptyTextView.setVisibility(View.GONE);
CatalogueCategoryItemAdapter adapter = new CatalogueCategoryItemAdapter(CatalogueItemScreen.this);
adapter.setCatalogueList(catalogueItemList);
listView.setAdapter(adapter);
setContentView(listView);
adapter.setCatalogueItemList(mCatalogueItemList);
mListView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
CatalogueLog.e("OnItemClickListener: position: " + position + ", Catalogue: " + catalogueItemList.get(position));
CatalogueLog.e("OnItemClickListener: position: " + position + ", Catalogue: " + mCatalogueItemList.get(position));
Intent intent = new Intent(CatalogueItemScreen.this, CatalogueVariableScreen.class);
intent.putExtra(Constants.DATA_KEY_SYS_ID, catalogueItemList.get(position).getSysId());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_ITEM_DESCRIPTION, catalogueItemList.get(position).getDescription());
intent.putExtra(Constants.DATA_KEY_SYS_ID, mCatalogueItemList.get(position).getSysId());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_ITEM_DESCRIPTION, mCatalogueItemList.get(position).getDescription());
startActivity(intent);
}
});
} else {
/*There is no catalogue items*/
TextView textView = new TextView(CatalogueItemScreen.this);
textView.setGravity(Gravity.CENTER);
textView.setText(R.string.no_catalogue_item_string);
setContentView(textView);
mEmptyTextView.setVisibility(View.VISIBLE);
mListView.setVisibility(View.GONE);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(menuItem);
}
}
......@@ -125,6 +125,7 @@ public class CatalogueScreen extends AppCompatActivity {
CatalogueLog.e("OnItemClickListener: position: "+position + ", Catalogue: "+catalogueList.get(position));
Intent intent = new Intent(CatalogueScreen.this, CatalogueItemScreen.class);
intent.putExtra(Constants.DATA_KEY_SYS_ID, catalogueList.get(position).getSysId());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_TITLE, catalogueList.get(position).getTitle());
startActivity(intent);
}
});
......@@ -137,5 +138,4 @@ public class CatalogueScreen extends AppCompatActivity {
}
return super.onOptionsItemSelected(menuItem);
}
}
......@@ -16,6 +16,7 @@ public class Constants {
*/
public static final String DATA_DATE_AND_TIME_PICKER_TITLE = "title";
public static final String DATA_KEY_SYS_ID = "sys_id";
public static final String DATA_KEY_CATALOGUE_TITLE = "catalogue_title";
public static final String DATA_KEY_CATALOGUE_ITEM_DESCRIPTION = "catalogue_item_des";
public static final String DATA_KEY_REFERENCE_TABLE_NAME = "table_name";
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/catalogue_item_content_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="10">
android:layout_height="@dimen/list_item_height"
android:weightSum="10"
android:paddingLeft="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:background="@drawable/background_with_border">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:layout_gravity="center"
android:layout_weight="2.5"
android:src="@android:drawable/ic_dialog_dialer" />
android:src="@drawable/dummy_image"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7.5"
android:layout_weight="7"
android:orientation="vertical"
android:padding="@dimen/small_margin">
android:layout_gravity="center"
android:paddingLeft="@dimen/small_margin">
<TextView
android:id="@+id/catalogue_category_item_adapter_name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/normal_text_size"
android:textStyle="bold"
android:lines="1" />
<TextView
android:id="@+id/catalogue_category_item_adapter_des_tv"
......@@ -33,7 +37,7 @@
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="2"
android:paddingTop="@dimen/small_margin"
android:textSize="@dimen/small_text_size" />
android:textSize="@dimen/small_text_size"
android:paddingTop="@dimen/small_margin" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="@android:color/white"
android:contentInsetEnd="0dp"
android:contentInsetRight="0dp"
android:contentInsetStart="0dp"
android:minHeight="?attr/actionBarSize"
android:padding="0dp"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/screen_bg_color">
<ListView
android:id="@+id/catalogue_item_screen_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/normal_margin"
android:background="@android:color/white"
android:divider="@android:color/white"
android:dividerHeight="@dimen/list_view_divider_height"
android:padding="@dimen/normal_margin"
android:scrollbars="none"
android:visibility="gone" />
<TextView
android:id="@+id/catalogue_item_screen_empty_text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:gravity="center"
android:text="@string/no_catalogue_item_string"
android:textSize="@dimen/extra_normal_text_size" />
</FrameLayout>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment