Skip to content

Commit

Permalink
Merge pull request #866 from JERR-lxm/master
Browse files Browse the repository at this point in the history
#92 #95 #550 已完成
  • Loading branch information
zengsn committed May 31, 2016
2 parents 1c9a392 + 367f539 commit 9848a84
Show file tree
Hide file tree
Showing 14 changed files with 912 additions and 18 deletions.
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>
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);

}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.view.MenuItem;

import edu.hzuapps.androidworks.homeworks.net1314080903122.Fragment.Net1314080903122_Category;
import edu.hzuapps.androidworks.homeworks.net1314080903122.Fragment.Net1314080903122_SmsHistory;

public class Net1314080903122_MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -41,6 +42,7 @@ private void initViews() {
{
@Override
public Fragment getItem(int position) {
if (position == 1)return new Net1314080903122_SmsHistory();
return new Net1314080903122_Category();
}

Expand Down
Loading

0 comments on commit 9848a84

Please sign in to comment.