Skip to content

Commit

Permalink
Removed some redundant linear layouts.
Browse files Browse the repository at this point in the history
Remove MesgEditText again.
Remove hard coded /data path.
Use File(File, "id");
  • Loading branch information
ldornin committed May 14, 2013
1 parent a2abc59 commit 3ce63e6
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 170 deletions.
6 changes: 3 additions & 3 deletions FinchFramework/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<uses-sdk android:minSdkVersion="7" />

<uses-permission android:name="android.permission.INTERNET" />

<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="true">
<activity android:name=".FinchWelcome"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Expand Down
9 changes: 6 additions & 3 deletions FinchFramework/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-14
android.library=true
# Project target.
target=android-16
4 changes: 2 additions & 2 deletions FinchFramework/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

<string name="app_name">FinchFramework</string>

<string name="connect">Connect a device</string>
<string name="discoverable">Make discoverable</string>

Expand All @@ -11,4 +11,4 @@
<string name="bluetooth_tools">Bluetooth tools</string>
<string name="animation_example">Animation</string>

</resources>
</resources>
66 changes: 33 additions & 33 deletions FinchFramework/src/com/finchframework/finch/FinchApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@
/**
* Provides the framework's Application subclass. This illustrates what
* you may need to do in an Application subclass.
*
* <p/>
* To get this class instantiated, you must refer to it in the
* application tag of the manifest.
*/
public class FinchApplication extends Application {
private final String TAG = this.getClass().getSimpleName();

@Override
public void onCreate() {
// First, call the parent class
super.onCreate();

// This is a place to put code that must manage storage across
// multiple activities, but it's better to keep most things in a
// database, rather than in memory
Log.i(TAG, "onCreate");
}

@Override
public void onTerminate() {
Log.i(TAG, "onTerminate");

}

@Override
public void onLowMemory() {
// In-memory caches should be thrown overboard here
Log.i(TAG, "onLowMemory");
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
Log.i(TAG, "onConifgurationChanged");
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, newConfig.toString());
}
}
private final String TAG = this.getClass().getSimpleName();

@Override
public void onCreate() {
// First, call the parent class
super.onCreate();

// This is a place to put code that must manage storage across
// multiple activities, but it's better to keep most things in a
// database, rather than in memory
Log.i(TAG, "onCreate");
}

@Override
public void onTerminate() {
Log.i(TAG, "onTerminate");

}

@Override
public void onLowMemory() {
// In-memory caches should be thrown overboard here
Log.i(TAG, "onLowMemory");
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
Log.i(TAG, "onConifgurationChanged");
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, newConfig.toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,24 @@
*/
public class FileHandler implements ResponseHandler {
private String mId;
private String mCacheDir;
private File mCacheDir;

public FileHandler(String cacheDir, String id) {
public FileHandler(File cacheDir, String id) {
mCacheDir = cacheDir;
mId = id;
}

public
String getFileName(String ID) {
return mCacheDir + "/" + ID;
public File getFile(String ID) {
return new File(mCacheDir, ID);
}

public void handleResponse(HttpResponse response, Uri uri)
throws IOException
{
throws IOException {
InputStream urlStream = response.getEntity().getContent();
FileOutputStream fout =
new FileOutputStream(getFileName(mId));
new FileOutputStream(getFile(mId));
byte[] bytes = new byte[256];
int r = 0;
int r;
do {
r = urlStream.read(bytes);
if (r >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,31 @@
* The cache directory is set in the constructor to the file handler factory.
*/
public class FileHandlerFactory {
private String mCacheDir;
private File mCacheDir;

public FileHandlerFactory(String cacheDir) {
public FileHandlerFactory(File cacheDir) {
mCacheDir = cacheDir;
init();
}

private void init() {
File cacheDir = new File(mCacheDir);
if (!cacheDir.exists()) {
cacheDir.mkdir();
if (!mCacheDir.exists()) {
mCacheDir.mkdir();
}
}

public FileHandler newFileHandler(String id) {
return new FileHandler(mCacheDir, id);
}

// not really used since ContentResolver uses _data field.
public File getFile(String ID) {
String cachePath = getFileName(ID);

File cacheFile = new File(cachePath);
if (cacheFile.exists()) {
return cacheFile;
}
return null;
}

public void delete(String ID) {
String cachePath = mCacheDir + "/" + ID;

File cacheFile = new File(cachePath);
File cacheFile = new File(mCacheDir, ID);
if (cacheFile.exists()) {
cacheFile.delete();
}
}

public String getFileName(String ID) {
return mCacheDir + "/" + ID;
return new File(mCacheDir, ID).toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ public abstract class RESTfulContentProvider extends ContentProvider {
private Map<String, UriRequestTask> mRequestsInProgress =
new HashMap<String, UriRequestTask>();

public RESTfulContentProvider(FileHandlerFactory fileHandlerFactory) {
public RESTfulContentProvider() {
}

public void setFileHandlerFactory(FileHandlerFactory fileHandlerFactory) {
mFileHandlerFactory = fileHandlerFactory;
}

public abstract Uri insert(Uri uri, ContentValues cv, SQLiteDatabase db);
public abstract Uri insert(Uri uri, ContentValues cv, SQLiteDatabase db);

private UriRequestTask getRequestTask(String queryText) {
return mRequestsInProgress.get(queryText);
Expand All @@ -53,10 +56,10 @@ public void requestComplete(String mQueryText) {
*
* @param requestTag unique tag identifying this request.
* @return The response handler created by a subclass used to parse the
* request response.
* request response.
*/
protected abstract ResponseHandler newResponseHandler(String requestTag);

UriRequestTask newQueryTask(String requestTag, String url) {
UriRequestTask requestTask;

Expand All @@ -73,7 +76,6 @@ UriRequestTask newQueryTask(String requestTag, String url) {
* Creates a new worker thread to carry out a RESTful network invocation.
*
* @param queryTag unique tag that identifies this request.
*
* @param queryUri the complete URI that should be access by this request.
*/
public void asyncQueryRequest(String queryTag, String queryUri) {
Expand Down
30 changes: 28 additions & 2 deletions FinchFramework/src/com/finchframework/finch/rest/RawResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,75 +29,101 @@ public RawResponse(Context c, int rawResource) {
Log.d(Finch.LOG_TAG, "exception from raw input stream", e);
}
}

public StatusLine getStatusLine() {
return null;
}

public void setStatusLine(StatusLine statusLine) {
}

public void setStatusLine(ProtocolVersion protocolVersion,
int i) {
}

public void setStatusLine(ProtocolVersion protocolVersion,
int i, String s) {
}

public void setStatusCode(int i)
throws IllegalStateException
{
throws IllegalStateException {
}

public void setReasonPhrase(String s)
throws IllegalStateException {
}

public HttpEntity getEntity() {
return mDebugEntity;
}

public void setEntity(HttpEntity httpEntity) {
}

public Locale getLocale() {
return null;
}

public void setLocale(Locale locale) {
}

public ProtocolVersion getProtocolVersion() {
return null;
}

public boolean containsHeader(String s) {
return false;
}

public Header[] getHeaders(String s) {
return new Header[0];
}

public Header getFirstHeader(String s) {
return null;
}

public Header getLastHeader(String s) {
return null;
}

public Header[] getAllHeaders() {
return new Header[0];
}

public void addHeader(Header header) {
}

public void addHeader(String s, String s1) {
}

public void setHeader(Header header) {
}

public void setHeader(String s, String s1) {
}

public void setHeaders(Header[] headers) {
}

public void removeHeader(Header header) {
}

public void removeHeaders(String s) {
}

public HeaderIterator headerIterator() {
return null;
}

public HeaderIterator headerIterator(String s) {
return null;
}

public HttpParams getParams() {
return null;
}

public void setParams(HttpParams httpParams) {
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@ public class UriRequestTask implements Runnable {

private RESTfulContentProvider mSiteProvider;
private String mRequestTag;

private int mRawResponse = -1;
// private int mRawResponse = R.raw.map_src;

public UriRequestTask(HttpUriRequest request,
ResponseHandler handler, Context appContext)
{
ResponseHandler handler, Context appContext) {
this(null, null, request, handler, appContext);
}

public UriRequestTask(String requestTag,
RESTfulContentProvider siteProvider,
HttpUriRequest request,
ResponseHandler handler, Context appContext)
{
ResponseHandler handler, Context appContext) {
mRequestTag = requestTag;
mSiteProvider = siteProvider;
mRequest = request;
Expand Down
Loading

0 comments on commit 3ce63e6

Please sign in to comment.