-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #866 from JERR-lxm/master
- Loading branch information
Showing
14 changed files
with
912 additions
and
18 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903122/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="edu.hzuapps.androidworks.homeworks.net1314080903122" | ||
> | ||
|
||
<uses-permission android:name="android.permission.READ_CONTACTS"/> | ||
<uses-permission android:name="android.permission.WRITE_CONTACTS"/> | ||
<uses-permission android:name="android.permission.SEND_SMS"/> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/net1314080903122_panda_icon" | ||
android:label="Festival_Sms" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".Net1314080903122_MainActivity" | ||
android:label="Festival_Sms" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".Net1314080903122_ChooseMsg" | ||
android:label="@string/title_activity_net1314080903122__choose_msg" | ||
android:theme="@style/AppTheme.NoActionBar" /> | ||
<activity | ||
android:name=".Net1314080903122_SendMsg" | ||
android:label="@string/title_activity_net1314080903122__send_msg" | ||
android:theme="@style/AppTheme.NoActionBar"></activity> | ||
|
||
<provider | ||
android:authorities="edu.hzuapps.androidworks.homeworks.sms.provider.SmsProvider" | ||
android:name=".db.Net1314080903122_SmsProvider"/> | ||
</application> | ||
|
||
</manifest> |
116 changes: 116 additions & 0 deletions
116
...hzuapps/androidworks/homeworks/net1314080903122/Fragment/Net1314080903122_SmsHistory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package edu.hzuapps.androidworks.homeworks.net1314080903122.Fragment; | ||
|
||
|
||
import android.content.Context; | ||
import android.database.Cursor; | ||
import android.os.Bundle; | ||
import android.support.v4.app.ListFragment; | ||
import android.support.v4.app.LoaderManager; | ||
import android.support.v4.content.CursorLoader; | ||
import android.support.v4.content.Loader; | ||
import android.support.v4.widget.CursorAdapter; | ||
import android.text.TextUtils; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import java.text.DateFormat; | ||
import java.text.SimpleDateFormat; | ||
|
||
import edu.hzuapps.androidworks.homeworks.net1314080903122.R; | ||
import edu.hzuapps.androidworks.homeworks.net1314080903122.bean.Net1314080903122_SendedMsg; | ||
import edu.hzuapps.androidworks.homeworks.net1314080903122.db.Net1314080903122_SmsProvider; | ||
import edu.hzuapps.androidworks.homeworks.net1314080903122.view.FlowLayout; | ||
|
||
/** | ||
* Created by Administrator on 2016/5/29. | ||
*/ | ||
public class Net1314080903122_SmsHistory extends ListFragment{ | ||
private static final int LOADER_ID = 1; | ||
private LayoutInflater mInflater; | ||
private CursorAdapter mCursorAdapter; | ||
|
||
@Override | ||
public void onViewCreated(View view, Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
mInflater = LayoutInflater.from(getActivity()); | ||
initLoader(); | ||
setupListAdapter(); | ||
} | ||
|
||
private void setupListAdapter() { | ||
mCursorAdapter = new CursorAdapter(getActivity(),null,false) { | ||
@Override | ||
public View newView(Context context, Cursor cursor, ViewGroup parent) { | ||
View view = mInflater.inflate(R.layout.net1314080903122_item_sended_msg, parent, false); | ||
return view; | ||
} | ||
|
||
@Override | ||
public void bindView(View view, Context context, Cursor cursor) { | ||
TextView msg = (TextView) view.findViewById(R.id.id_tv_msg); | ||
FlowLayout fl = (FlowLayout) view.findViewById(R.id.id_fl_contacts); | ||
TextView fes = (TextView) view.findViewById(R.id.id_tv_fes); | ||
TextView date = (TextView) view.findViewById(R.id.id_tv_date); | ||
|
||
msg.setText(cursor.getString(cursor.getColumnIndex(Net1314080903122_SendedMsg.COLUMN_MSG))); | ||
fes.setText(cursor.getString(cursor.getColumnIndex(Net1314080903122_SendedMsg.COLUMN_FES_NAME))); | ||
long dateVal=cursor.getLong(cursor.getColumnIndex(Net1314080903122_SendedMsg.COLUMN_DATE)); | ||
date.setText(parseDate(dateVal)); | ||
String names = cursor.getString(cursor.getColumnIndex(Net1314080903122_SendedMsg.COLUMN_NAMES)); | ||
if (TextUtils.isEmpty(names)) | ||
{ | ||
return; | ||
} | ||
fl.removeAllViews(); | ||
for (String name : names.split(":")) | ||
{ | ||
addTag(name,fl); | ||
} | ||
} | ||
}; | ||
setListAdapter(mCursorAdapter); | ||
} | ||
|
||
DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
private String parseDate(long dateVal) { | ||
return df.format(dateVal); | ||
} | ||
|
||
|
||
|
||
private void addTag(String name, FlowLayout fl) { | ||
TextView tv = (TextView) mInflater.inflate(R.layout.net1314080903122_tag, fl, false); | ||
tv.setText(name); | ||
fl.addView(tv); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
private void initLoader() { | ||
getLoaderManager().initLoader(LOADER_ID, null,new LoaderManager.LoaderCallbacks<Cursor>() { | ||
@Override | ||
public Loader<Cursor> onCreateLoader(int id, Bundle args) { | ||
CursorLoader loader = new CursorLoader(getActivity(), Net1314080903122_SmsProvider.URI_SMS_ALL,null,null,null,null); | ||
return loader; | ||
} | ||
|
||
@Override | ||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) { | ||
if (loader.getId() == LOADER_ID) | ||
{ | ||
mCursorAdapter.swapCursor(data); | ||
} | ||
} | ||
|
||
@Override | ||
public void onLoaderReset(Loader<Cursor> loader) { | ||
mCursorAdapter.swapCursor(null); | ||
|
||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.