Android Open Source - HistoryCleanerPro Profile Fragment






From Project

Back to project page HistoryCleanerPro.

License

The source code is released under:

Copyright (c) 2014, John Phillips All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project HistoryCleanerPro listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ayros.historycleaner.ui;
//  ww  w .ja  va2  s  .co m
import java.util.List;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

import com.ayros.historycleaner.ProfileAdapter;
import com.ayros.historycleaner.R;
import com.ayros.historycleaner.cleaning.Profile;
import com.ayros.historycleaner.cleaning.ProfileList;

public class ProfileFragment extends Fragment implements OnClickListener, OnProfileUpdated
{
  protected class ConfirmLoadListener implements DialogInterface.OnClickListener
  {
    private Profile profile;

    public ConfirmLoadListener(Profile p)
    {
      profile = p;
    }

    public void onClick(DialogInterface dialog, int whichButton)
    {
      ProfileList.get(null).copyFrom(profile);
      sendProfileUpdatedMessage();
    }
  }

  public static ProfileFragment newInstance()
  {
    ProfileFragment fragment = new ProfileFragment();
    Bundle args = new Bundle();
    fragment.setArguments(args);

    return fragment;
  }

  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
  {
    View rootView = inflater.inflate(R.layout.frag_profile, container, false);

    return rootView;
  }

  @Override
  public void onClick(View v)
  {
    final Profile p = (Profile)v.getTag();
    Button btn = (Button)v;

    if (btn.getText().equals(getResources().getString(R.string.profile_list_row_load)))
    {
      AlertDialog.Builder confirmLoad = new AlertDialog.Builder(ProfileFragment.this.getActivity());
      confirmLoad.setTitle("Load Profile");
      confirmLoad.setMessage("Do you want to load this profile? (It will replace the currently selected items)");

      confirmLoad.setPositiveButton(android.R.string.yes, new ConfirmLoadListener(p));
      confirmLoad.setNegativeButton(android.R.string.no, null);

      confirmLoad.show();
    }
    else if (btn.getText().equals(getResources().getString(R.string.profile_list_row_settings)))
    {
      final Dialog profileSettings = new Dialog(ProfileFragment.this.getActivity());
      profileSettings.setTitle("Profile Settings");

      profileSettings.setContentView(R.layout.profile_item_settings);

      Button saveButton = (Button)profileSettings.findViewById(R.id.profile_item_settings_btnSave);
      saveButton.setOnClickListener(new OnClickListener()
      {
        @Override
        public void onClick(View v)
        {
          Toast.makeText(ProfileFragment.this.getActivity(), "Changes saved successfully!",
            Toast.LENGTH_SHORT).show();
          // p.saveChanges();
          sendProfileUpdatedMessage();
          profileSettings.dismiss();
        }
      });

      Button cancelButton = (Button)profileSettings.findViewById(R.id.profile_item_settings_btnCancel);
      cancelButton.setOnClickListener(new OnClickListener()
      {
        @Override
        public void onClick(View v)
        {
          profileSettings.dismiss();
        }
      });

      Button deleteButton = (Button)profileSettings.findViewById(R.id.profile_item_settings_btnDelete);
      deleteButton.setOnClickListener(new OnClickListener()
      {
        @Override
        public void onClick(View v)
        {
          ProfileList.delete(p);
          profileSettings.dismiss();
          sendProfileUpdatedMessage();
        }
      });

      profileSettings.show();
    }
  }

  @Override
  public void onProfileUpdated()
  {
    refreshProfileList();
  }

  @Override
  public void onResume()
  {
    super.onResume();

    onProfileUpdated();
  }

  public void refreshProfileList()
  {
    ListView lv = (ListView)this.getView().findViewById(R.id.profile_list);

    List<Profile> profList = ProfileList.getClonedList(false);

    Profile[] profData = profList.toArray(new Profile[profList.size()]);

    ProfileAdapter adapter = new ProfileAdapter(this.getActivity(), R.layout.profile_list_item, profData, this);

    lv.setAdapter(adapter);
  }

  public void sendProfileUpdatedMessage()
  {
    ((OnProfileUpdated)getActivity()).onProfileUpdated();
  }
}




Java Source Code List

com.ayros.historycleaner.Globals.java
com.ayros.historycleaner.ProfileAdapter.java
com.ayros.historycleaner.UIRunner.java
com.ayros.historycleaner.cleaning.CategoryList.java
com.ayros.historycleaner.cleaning.Category.java
com.ayros.historycleaner.cleaning.CleanItem.java
com.ayros.historycleaner.cleaning.CleanListener.java
com.ayros.historycleaner.cleaning.Cleaner.java
com.ayros.historycleaner.cleaning.ProfileList.java
com.ayros.historycleaner.cleaning.Profile.java
com.ayros.historycleaner.cleaning.SimpleDatabaseItem.java
com.ayros.historycleaner.cleaning.SimpleFileItem.java
com.ayros.historycleaner.cleaning.items._AdobeReader_Recent.java
com.ayros.historycleaner.cleaning.items._FirefoxBeta_Cache.java
com.ayros.historycleaner.cleaning.items._FirefoxBeta_Cookies.java
com.ayros.historycleaner.cleaning.items._FirefoxBeta_History.java
com.ayros.historycleaner.cleaning.items._FirefoxBeta_LocalStorage.java
com.ayros.historycleaner.cleaning.items._FirefoxBeta_OpenTabs.java
com.ayros.historycleaner.cleaning.items._Firefox_Cache.java
com.ayros.historycleaner.cleaning.items._Firefox_Cookies.java
com.ayros.historycleaner.cleaning.items._Firefox_History.java
com.ayros.historycleaner.cleaning.items._Firefox_LocalStorage.java
com.ayros.historycleaner.cleaning.items._Firefox_OpenTabs.java
com.ayros.historycleaner.cleaning.items._ONEBrowser_Cache.java
com.ayros.historycleaner.cleaning.items._ONEBrowser_LocalStorage.java
com.ayros.historycleaner.cleaning.items._System_BrowserHistory.java
com.ayros.historycleaner.cleaning.items._System_Cache.java
com.ayros.historycleaner.cleaning.items._System_Clipboard.java
com.ayros.historycleaner.cleaning.items._System_FrequentContacts.java
com.ayros.historycleaner.cleaning.items._System_RecentCalls.java
com.ayros.historycleaner.cleaning.items._System_SMS.java
com.ayros.historycleaner.helpers.DBHelper.java
com.ayros.historycleaner.helpers.DatabaseModifier.java
com.ayros.historycleaner.helpers.Helper.java
com.ayros.historycleaner.helpers.Logger.java
com.ayros.historycleaner.helpers.PrefsModifier.java
com.ayros.historycleaner.helpers.RootHelper.java
com.ayros.historycleaner.helpers.XML.java
com.ayros.historycleaner.locale.Constants.java
com.ayros.historycleaner.locale.bundle.BundleScrubber.java
com.ayros.historycleaner.locale.bundle.PluginBundleManager.java
com.ayros.historycleaner.locale.receiver.FireReceiver.java
com.ayros.historycleaner.locale.ui.AbstractPluginActivity.java
com.ayros.historycleaner.locale.ui.EditPluginActivity.java
com.ayros.historycleaner.ui.CleanFragment.java
com.ayros.historycleaner.ui.DataViewActivity.java
com.ayros.historycleaner.ui.HelpActivity.java
com.ayros.historycleaner.ui.MainActivity.java
com.ayros.historycleaner.ui.OnProfileUpdated.java
com.ayros.historycleaner.ui.ProfileFragment.java
com.ayros.historycleaner.ui.ShortcutActivity.java
com.ayros.historycleaner.ui.ShortcutCleanActivity.java
com.twofortyfouram.locale.BreadCrumber.java
com.twofortyfouram.locale.Constants.java
com.twofortyfouram.locale.Intent.java
com.twofortyfouram.locale.PackageUtilities.java