Skip to content
This repository was archived by the owner on Aug 21, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ android {

compile files('libs/PBKDF2-1.0.4.jar')
testCompile 'junit:junit:4.12'

androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'

}
}
dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package org.ole.learning.planet.planetlearning;

import android.app.Application;
import android.text.TextUtils;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;

public class AppController extends Application {

public static final String TAG = AppController.class.getSimpleName();

private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;

private static AppController mInstance;

@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}

public static synchronized AppController getInstance() {
return mInstance;
}

public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}

return mRequestQueue;
}

public ImageLoader getImageLoader() {
getRequestQueue();
if (mImageLoader == null) {
mImageLoader = new ImageLoader(this.mRequestQueue,
new LruBitmapCache());
}
return this.mImageLoader;
}

public <T> void addToRequestQueue(Request<T> req, String tag) {
// set the default tag if tag is empty
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}

public <T> void addToRequestQueue(Request<T> req) {
req.setTag(TAG);
getRequestQueue().add(req);
}

public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.ole.learning.planet.planetlearning;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;

public class CustomListAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater;
private List<Resource> resourceItems;
public Resources res;

ImageLoader imageLoader = AppController.getInstance().getImageLoader();
public CustomListAdapter(Activity activity, List<Resource> resourceItems) {
this.activity = activity;
this.resourceItems = resourceItems;
}

@Override
public int getCount() {
return resourceItems.size();
}

@Override
public Object getItem(int location) {
return resourceItems.get(location);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

if (inflater == null)
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
convertView = inflater.inflate(R.layout.list_row, null);

if (imageLoader == null)
imageLoader = AppController.getInstance().getImageLoader();
// NetworkImageView thumbNail = (NetworkImageView) convertView.findViewById(R.id.thumbnail);
ImageView thumbNail = (ImageView) convertView.findViewById(R.id.thumbnail);
TextView title = (TextView) convertView.findViewById(R.id.title);
TextView rating = (TextView) convertView.findViewById(R.id.rating);
TextView genre = (TextView) convertView.findViewById(R.id.genre);
TextView year = (TextView) convertView.findViewById(R.id.releaseYear);

// getting resource data for the row
Resource r = resourceItems.get(position);

// thumbnail image
thumbNail.setBackgroundResource(r.getThumbnailUrl());
//thumbNail.setImageUrl(r.getThumbnailUrl(), imageLoader);

// title
title.setText(r.getTitle());

// rating
//rating.setText(" " + String.valueOf(r.getDescription()));
rating.setText(" ");

// genre
String genreStr = "";
genreStr = genreStr.length() > 0 ? genreStr.substring(0,
genreStr.length() - 2) : genreStr;
genre.setText(genreStr);

// release Rating
year.setText(String.valueOf(r.getRating()));

return convertView;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
restorePref();
LoadMyLibraryList();

list = (ListView) rootView.findViewById(R.id.material_list);
list = rootView.findViewById(R.id.material_list);
adapter = new ListViewAdapter_myLibrary(resIDArrayList, getActivity(), context, materialList);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
Expand All @@ -104,17 +104,6 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
}

public void LoadMyLibraryList() {
/*
try {
AndroidContext androidContext = new AndroidContext(context);
Manager manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS);
database = manager.getDatabase("resources");
database.delete();
} catch (Exception e) {
e.printStackTrace();
}
*/

try {
manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS);
Database shelf_db = manager.getExistingDatabase("shelf");
Expand All @@ -137,13 +126,13 @@ public void LoadMyLibraryList() {
Document shelf_doc = shelf_db.getExistingDocument(docId);
Map<String, Object> shelf_properties = shelf_doc.getProperties();
///Map<String, Object> shadowresources_properties = null;
if (sys_usercouchId.equals((String) shelf_properties.get("memberId"))) {
if (sys_usercouchId.equals(shelf_properties.get("memberId"))) {
String myresTitile = ((String) shelf_properties.get("resourceTitle"));
String myresId = ((String) shelf_properties.get("resourceId"));
resourceTitleList[rsLstCnt] = myresTitile;
resourceIdList[rsLstCnt] = myresId;
resIDArrayList.add(myresId);
Log.e(TAG, "Resource Title " + (String) shelf_properties.get("resourceTitle"));
Log.e(TAG, "Resource Title " + shelf_properties.get("resourceTitle"));
String buildDecript = "Description not available.";
String buildRating = "0";
String avgRating = "0";
Expand All @@ -159,19 +148,19 @@ public void LoadMyLibraryList() {
Log.e(TAG, "Completed going to if " + myresTitile);
if (shadowresources_doc != null) {
Map<String, Object> shadowresources_properties = shadowresources_doc.getProperties();
buildDecript = "Author : " + (String) shadowresources_properties.get("author") + " Language : " + (String) shadowresources_properties.get("language") + " \n" +
" Resource Type : " + (String) shadowresources_properties.get("Medium") + " \n" +
"Date Uploaded : " + (String) shadowresources_properties.get("uploadDate") + " ";
buildRating = (((String) shadowresources_properties.get("averageRating")) == "") ? "2.2" : (String) shadowresources_properties.get("averageRating");
buildDecript = "Author : " + shadowresources_properties.get("author") + " Language : " + shadowresources_properties.get("language") + " \n" +
" Resource Type : " + shadowresources_properties.get("Medium") + " \n" +
"Date Uploaded : " + shadowresources_properties.get("uploadDate") + " ";
buildRating = (shadowresources_properties.get("averageRating") == "") ? "2.2" : (String) shadowresources_properties.get("averageRating");
avgRating = shadowresources_properties.get("averageRating").toString();
Log.e(TAG, "OBJECT FOUND - Item found in shadow resources " + myresTitile);
}
if (local_downloaded_doc != null) {
Log.e(TAG, "OBJECT ERROR - Item not in shadow resources checking local resources " + myresTitile);
Map<String, Object> local_downloaded_properties = local_downloaded_doc.getProperties();
Log.e(TAG, "OBJECT FOUND - Item found in local resources " + myresTitile);
buildDecript = "Author : " + (String) local_downloaded_properties.get("author") + " Language : " + (String) local_downloaded_properties.get("language") + " \n" +
"Date Uploaded : " + (String) local_downloaded_properties.get("uploadDate") + " ";
buildDecript = "Author : " + local_downloaded_properties.get("author") + " Language : " + local_downloaded_properties.get("language") + " \n" +
"Date Uploaded : " + local_downloaded_properties.get("uploadDate") + " ";
resourceDownloaded = true;
Log.e(TAG, "Resource Downloaded True " + myresTitile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ public void onClick(View view) {
if (getSystemInfo()) {
if (authenticateUser()) {
if (updateActivityLog()) {
Intent intent = new Intent(context, User_Dashboard.class);
Intent intent = new Intent(context, Main_Dashboard.class);
// Intent intent = new Intent(context, User_Dashboard.class);
//Intent intent = new Intent(context, FullscreenActivity.class);
Log.e(TAG, "Opening Dashboard");
startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.ole.learning.planet.planetlearning;

import com.android.volley.toolbox.*;
import com.android.volley.toolbox.ImageLoader;

import com.android.volley.toolbox.ImageLoader.ImageCache;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;

public class LruBitmapCache extends LruCache<String, Bitmap> implements ImageCache {
public static int getDefaultLruCacheSize() {
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
final int cacheSize = maxMemory / 8;

return cacheSize;
}

public LruBitmapCache() {
this(getDefaultLruCacheSize());
}

public LruBitmapCache(int sizeInKiloBytes) {
super(sizeInKiloBytes);
}

@Override
protected int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight() / 1024;
}

@Override
public Bitmap getBitmap(String url) {
return get(url);
}

@Override
public void putBitmap(String url, Bitmap bitmap) {
put(url, bitmap);
}
}
Loading