Back to project page KeepMySecret.
The source code is released under:
GNU General Public License
If you think the Android project KeepMySecret listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package keepmysecretapp.app.com.keepmysecretapp.fragments.presentation; /*from www . j a v a 2 s . c om*/ import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ListView; import java.util.ArrayList; import java.util.List; import keepmysecretapp.app.com.keepmysecretapp.R; import keepmysecretapp.app.com.keepmysecretapp.activities.creation.CreateNewEntryActivity; import keepmysecretapp.app.com.keepmysecretapp.activities.MainActivity; import keepmysecretapp.app.com.keepmysecretapp.adapters.GroupEntryAdapter; import keepmysecretapp.app.com.keepmysecretapp.dao.Dao; import keepmysecretapp.app.com.keepmysecretapp.dao.GroupDao; import keepmysecretapp.app.com.keepmysecretapp.db.DbContext; import keepmysecretapp.app.com.keepmysecretapp.db.EntryType; import keepmysecretapp.app.com.keepmysecretapp.other.Constants; import keepmysecretapp.app.com.keepmysecretapp.types.ListEntry; public class TextKeeperFragment extends Fragment { private ListView groupsList; private Button mCreateGroupButton; private static String tag = "textKeeper"; public static TextKeeperFragment newInstance(int sectionNumber) { TextKeeperFragment fragment = new TextKeeperFragment(); Bundle args = new Bundle(); args.putInt(Constants.ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; } public TextKeeperFragment() { } @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_keeper_text, container, false); ArrayList<ListEntry> groups = getGroupList(); groupsList = (ListView) rootView.findViewById(R.id.GroupsList); groupsList.setAdapter(new GroupEntryAdapter(getActivity(), groups)); mCreateGroupButton = (Button) rootView.findViewById(R.id.addGroupButton); initListeners(mCreateGroupButton); return rootView; } @Override public void onAttach(Activity activity) { super.onAttach(activity); ((MainActivity) activity).onSectionAttached( getArguments().getInt(Constants.ARG_SECTION_NUMBER)); } private void initListeners(Button button) { if (button == null) { Log.e(tag, "button NULL"); return; } button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent toCreateActivity = new Intent(getActivity(), CreateNewEntryActivity.class); toCreateActivity.putExtra(Constants.ENTRY_TYPE, EntryType.GROUPS.getName()); startActivity(toCreateActivity); } }); } public ArrayList<ListEntry> getGroupList() { /* In the future, get list below from database */ DbContext dbContext = DbContext.getInstance(getActivity()); Dao dao = new GroupDao(dbContext); ArrayList<ListEntry> retList = new ArrayList<ListEntry>(); List<Object> entries = dao.getAllEntries(); for (Object entry : entries) { retList.add((ListEntry) entry); } // GroupListEntry entry = new GroupListEntry(); // entry.setName("????? "); // entry.setDescribe("??????? ?????? ?????????"); // retList.add(entry); // // entry = new GroupListEntry(); // entry.setName("??????"); // entry.setDescribe("??????? ??????? ?????????"); // retList.add(entry); return retList; } }