YXDroid v1.0

YXDroid is a free, open source, simple , follow the Android open-source development framework agreement Apache2 released its purpose is to develop a simple , rapid conduct
Android application development , including the Android mvc, simple sqlite orm, ioc module encapsulation Android httpclitent the http module ,
Have the format quickly build file caching function without considering the cache file , you can very easily implement caching , file-based caching module also implements image cache function ,
When loading images in android in question for oom , and to load images dislocation issues are easily resolved. He also includes a utility class to develop a mobile phone application frequently ,
Such as log management, configuration file management , android download module , a network change detection and much more .

Currently YXDroid has the following modules:

* MVC module: separation of view and model.

* Ioc module : android in ioc module , fully annotated way to bind UI can be read in the resource res , and the initialization of the object.

* Database module : android in orm framework , using the thread pool for sqlite operation.
*
* Http module : http data encapsulated by httpclient request supports asynchronous and synchronous load .

* Cache Module: cache can achieve good through simple configuration and design of the cache can be freely configured

* Picture Cache Module : imageview load images without regard to when the picture is loaded container oom and android flick occurred during the time the photographs dislocation phenomena .

* Configuration Module : You can achieve a simple configuration pairing operation , the current profile can support Preference, Properties to configure access .

* Log Print Module : You can easily achieve faster print the log , support the expansion of the log printing , the current support for sdcard written to the local print and console Print

* Download module : you can simply realize multi-thread download, background download, HTTP for downloading control , such as start , pause, delete , and so on .

* Network status detection module : when the network status changes detects it .


Use YXDroid rapid development framework needs to have the following rights:


< - ! Access the Internet permissions needed to add - >
<uses-permission android:name="android.permission.INTERNET" />
<-! SDCARD read and write permissions needed to add - >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
< - ! Network state detection permissions needed to add - >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     Configuration:
     <receiver android:name="com.yx.util.netstate.TANetworkStateReceiver">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </ intent-filter>
        </ receiver>
 <application
        android: name = "com.yx.TAApplication">
      application must be configured above format

Activity must inherit TAActivity
----
YXDroid use:
More about YXDroid introduction ( finishing )
MVC module
* MVC module: separation of view and model.

  getTAApplication (). registerCommand (R.string.comand,
        TAIdentityCommand.class);
getTAApplication (). registerCommand (R.string.comand,
TAIdentityCommand.class);
TALogger.addLogger (new TAPrintToFileLogger ());
TARequest request = new TARequest ();
doCommand (R.string.comand, request, new TAIResponseListener ()
{

@ Override
public void onStart (TAResponse response)
{
/ / TODO Auto-generated method stub

}

@ Override
public void onSuccess (TAResponse response)
{
/ / TODO Auto-generated method stub

}

@ Override
public void onRuning (TAResponse response)
{
/ / TODO Auto-generated method stub

}

@ Override
public void onFailure (TAResponse response)
{
/ / TODO Auto-generated method stub

}

}, False, true, true);
    
    
    
  
package com.yx.mvc.command;

import com.yx.mvc.common.TAIResponseListener;
import com.yx.mvc.common.TARequest;
import com.yx.mvc.common.TAResponse;

public class TAIdentityCommand extends TACommand
{
  @ Override
protected void executeCommand ()
{
/ / TODO Auto-generated method stub
TARequest request = getRequest ();
TAResponse response = new TAResponse ();
response.setTag (request.getTag ());
response.setData (request.getData ());
response.setActivityKey ((String) request.getActivityKey ());
response.setActivityKeyResID (request.getActivityKeyResID ());
setResponse (response);
notifyListener (true);
}

protected void notifyListener (boolean success)
{
TAIResponseListener responseListener = getResponseListener ();
if (responseListener! = null)
{
onComandUpdate (command_success);
}
}
}



ioc module to use:
* Fully annotated way to bind UI can be read in the resource res , and the initialization of the object.


public class YXDroidDemoActivity extends TAActivity {

     
@ TAInject
Entity entity; / / currently only on the no-argument constructor initializes
@ @ TAInject (id = R.string.app_name)
String appNameString;
@ TAInjectResource (id = R.attr.test)
int [] test;
@ TAInjectView (id = R.id.add);
Button addButton;
}



Database module
* Android in orm framework , using the thread pool for sqlite operation.


public class YXDroidDemoActivity extends TAActivity {

   TASQLiteDatabasePool sqlitePool = getTAApplication ()
. getSQLiteDatabasePool ();
TASQLiteDatabase sqliteDatabase = sqlitePool.getSQLiteDatabase ();
/ / Use the
sqliteDatabase.insert (entity);
sqlitePool.returnSQLiteDatabase (sqliteDatabase);
 
}


Http module to use:
Asynchronous get Methods

  AsyncHttpClient client = new AsyncHttpClient ();
client.get ("http://www.YXDroid.cn/", new AsyncHttpResponseHandler ()
{
@ Override
public void onSuccess (String content)
{
/ / TODO Auto-generated method stub
super.onSuccess (content);
TALogger.d (LoginActivity.this, content);
}

@ Override
public void onStart ()
{
/ / TODO Auto-generated method stub
super.onStart ();
}

@ Override
public void onFailure (Throwable error)
{
/ / TODO Auto-generated method stub
super.onFailure (error);
}

@ Override
public void onFinish ()
{
/ / TODO Auto-generated method stub
super.onFinish ();
}

} ) ;

Http module to use:
Synchronous get Methods

  TASyncHttpClient client = new TASyncHttpClient ();
  client.get ("http://www.YXDroid.cn/", new AsyncHttpResponseHandler ()
{
@ Override
public void onSuccess (String content)
{
/ / TODO Auto-generated method stub
super.onSuccess (content);
TALogger.d (LoginActivity.this, content);
}

@ Override
public void onStart ()
{
/ / TODO Auto-generated method stub
super.onStart ();
}

@ Override
public void onFailure (Throwable error)
{
/ / TODO Auto-generated method stub
super.onFailure (error);
}

@ Override
public void onFinish ()
{
/ / TODO Auto-generated method stub
super.onFinish ();
}

} ) ;

Upload files using http module or submit data to the server (post method )

RequestParams params = new RequestParams ();
  params.put ("username", "white_cat");
params.put ("password", "123456");
params.put ("email", "2640017581@qq.com");
params.put ("profile_picture", new File ("/ mnt / sdcard / testpic.jpg")); / / upload files
params.put ("profile_picture2", inputStream); / / upload data stream
params.put ("profile_picture3", new ByteArrayInputStream (bytes)); / / submit byte stream
client.post ("http://www.YXDroid.cn/", new AsyncHttpResponseHandler ()
{
@ Override
public void onSuccess (String content)
{
/ / TODO Auto-generated method stub
super.onSuccess (content);
TALogger.d (LoginActivity.this, content);
}

@ Override
public void onStart ()
{
/ / TODO Auto-generated method stub
super.onStart ();
}

@ Override
public void onFailure (Throwable error)
{
/ / TODO Auto-generated method stub
super.onFailure (error);
}

@ Override
public void onFinish ()
{
/ / TODO Auto-generated method stub
super.onFinish ();
}

} ) ;
}


----

Download files using http :
* Support for HTTP, or begin at any time to stop the download task task

    AsyncHttpClient syncHttpClient = new AsyncHttpClient ();
  FileHttpResponseHandler fHandler = new FileHttpResponseHandler (
TAExternalOverFroyoUtils.getDiskCacheDir (TestActivity.this,
"sdfsdfsdf"). getAbsolutePath ())
{


@ Override
public void onProgress (String speed, String progress) {
/ / TODO Auto-generated method stub
super.onProgress (speed, progress);
TALogger.v (TestActivity.this, progress + "--------" + speed);}

@ Override
public void onFailure (Throwable error) {
/ / TODOAuto-generated method stub
super.onFailure (error);}

@ Override
public void onSuccess (byte [] binaryData) {
/ / TODOAuto-generated method stub
super.onSuccess (binaryData);
TALogger.d (TestActivity.this, "kaishi8 a " ) ; } } ;
syncHttpClient. download (
"http://static.qiyi.com/ext/common/iQIYI/QIYImedia_4_01.exe",
fHandler);
         / / Stop
        fHandler.setInterrupt (interrupt);
        


Pictures modular approach
* Imageview load images without regard to when the picture is loaded container oom and android flick occurred during the time the photographs dislocation phenomena .

package com.test;
import com.yx.TAApplication;
import com.yx.util.bitmap.TABitmapCacheWork;
import com.yx.util.bitmap.TADownloadBitmapHandler;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class Adapter extends BaseAdapter
{
  TABitmapCacheWork imageFetcher;
Context mContext;

public Adapter (Context context, TAApplication application)
{
TADownloadBitmapHandler downloadBitmapFetcher = new TADownloadBitmapHandler (
context, 100);
imageFetcher = new TABitmapCacheWork (context);
imageFetcher.setProcessDataHandler (downloadBitmapFetcher);
imageFetcher.setFileCache (application.getFileCache ());
this.mContext = context;
}

@ Override
public int getCount ()
{
/ / TODO Auto-generated method stub
return Images.imageThumbUrls.length;
}

@ Override
public Object getItem (int position)
{
/ / TODO Auto-generated method stub
return Images.imageThumbUrls [position];
}

@ Override
public long getItemId (int position)
{
/ / TODO Auto-generated method stub
return position;
}

@ Override
public View getView (int position, View convertView, ViewGroup parent)
{
/ / TODO Auto-generated method stub
LayoutInflater inflater = (LayoutInflater) mContext
. getSystemService (Context.LAYOUT_INFLATER_SERVICE);
View baseView = inflater.inflate (R.layout.login_adapter, null);
final ImageView imageView = (ImageView) baseView
. findViewById (R.id.imageView);
     / / Load picture
imageFetcher.loadFormCache (getItem (position), imageView);
return baseView;
}
}



Use
  @ TAInjectView (id = R.id.gridView)
GridView gridView;
Adapter adapter = new Adapter (this, getTAApplication ());
gridView.setAdapter (adapter);
`` `

Cache module method
* Very simple to achieve cache to cache as an example of a simple file
* Download processing class

package com.test.file;

import com.yx.util.cache.TAProcessDataHandler;
/ / Download processing class
public class TAProcessStringHandler extends TAProcessDataHandler
{
  @ Override
public byte [] processData (Object data)
{
/ / TODO Auto-generated method stub
String mynameString = "white_cat";
/ / Here for data processing , such as downloading things like, converted to byte [] buffer storage for use
return mynameString.getBytes ();
}
}

* Cache results returned operations class

package com.test.file;

import android.widget.TextView;

import com.yx.util.cache.TACallBackHandler;

public class TAStringCallBackHandler extends TACallBackHandler <TextView>
{
  @ Override
public void onStart (TextView t, Object data)
{
/ / TODO Auto-generated method stub
super.onStart (t, data);
}

@ Override
public void onSuccess (TextView t, Object data, byte [] buffer)
{
/ / TODO Auto-generated method stub
super.onSuccess (t, data, buffer);
}

@ Override
public void onFailure (TextView t, Object data)
{
/ / TODO Auto-generated method stub
super.onFailure (t, data);
}
}

* Calls

TAFileCacheWork <TextView> taFileCacheWork = new TAFileCacheWork <TextView> ();
  taFileCacheWork.setFileCache (getTAApplication () getFileCache ().);
taFileCacheWork.setCallBackHandler (new TAStringCallBackHandler ());
taFileCacheWork.setProcessDataHandler (new TAProcessStringHandler ());
taFileCacheWork.loadFormCache ("http://www.baidu.com", textView);
`` `

Print module to use
You can easily achieve faster print the log , support the expansion of the log printing , the current support for sdcard written to the local print and console Print
Add a print device
TALogger.addLogger (new TAPrintToFileLogger ());
Called Print
TALogger.addLogger (new TAPrintToFileLogger ());
TALogger.d (TestActivity.this, "test");



Download module
You can simply realize multi-thread download, background download, HTTP for downloading control , such as start , pause, delete , and so on .

private DownloadManager downloadManager;
downloadManager = DownloadManager.getDownloadManager ();
downloadManager.setDownLoadCallback (new DownLoadCallback ()
{
@ Override
public void onSuccess (String url)
{

}

@ Override
public void onLoading (String url, String speed, String progress)
{
/ / TODO Auto-generated method stub


}
} ) ;
/ / Add
downloadManager.addHandler (url);
/ / Continue
downloadManager.continueHandler (url);
/ / Pause
downloadManager.pauseHandler (url);
/ / Delete
downloadManager.deleteHandler (url);
/ /

* Background Download

private IDownloadService downloadService;
ServiceConnection serviceConnection = new ServiceConnection ()
{

@ Override
public void onServiceDisconnected (ComponentName name)
{
/ / TODO Auto-generated method stub

}

@ Override
public void onServiceConnected (ComponentName name, IBinder service)
{
/ / TODO Auto-generated method stub
downloadService = (IDownloadService) service;
}
} ;

/ / Add tasks
downloadService.addTask (url)
/ / Pause task
 downloadService.pauseTask (url)
 / / Continue the task
 downloadService.continueTask (url)
 / / Delete the task
downloadService.deleteTask (url)


Configuration Mode
Can achieve a simple pairing configuration operations, the current profile can support Preference, Properties for configuration access

TAIConfig config = application
. getConfig (TAApplication.PROPERTIESCONFIG);
Entity entity = new Entity ();
entity.setB (false);
entity.setD (10);
entity.setI (1);
entity.setF (1f);
config.setConfig (entity);
Entity cEntity = config.getConfig (Entity.class);
textView.setText (cEntity.toString ());



Network status monitoring module
When the network status changes be monitored .

 TANetworkStateReceiver.registerObserver (new TANetChangeObserver ()
{
@ Override
public void onConnect (netType type)
{
/ / TODO Auto-generated method stub
super.onConnect (type);
Toast.makeText (TestActivity.this, "onConnect",
. Toast.LENGTH_SHORT) show ();
}

@ Override
public void onDisConnect ()
{
/ / TODO Auto-generated method stub
super.onDisConnect ();
Toast.makeText (TestActivity.this, "onDisConnect",
. Toast.LENGTH_SHORT) show ();
}
} ) ;


Need permission to open
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    
    Configuration:
     <receiver android:name="com.yx.util.netstate.TANetworkStateReceiver">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </ intent-filter>
        </ receiver>