Android Open Source - PrincePolo Select Repository Fragment






From Project

Back to project page PrincePolo.

License

The source code is released under:

GNU General Public License

If you think the Android project PrincePolo 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 se.agile.activities;  
//from  w  w w .j av a 2  s  . co m
import java.util.ArrayList;

import se.agile.activities.MainActivity.VIEW;
import se.agile.asynctasks.RequestListenerAdapter;
import se.agile.asynctasks.RequestRepositories;
import se.agile.githubdata.File;
import se.agile.githubdata.Repository;
import se.agile.model.PreferenceListener;
import se.agile.model.Preferences;
import se.agile.model.Preferences.PREF_KEY;
import se.agile.model.TemporaryStorage;
import se.agile.princepolo.R;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class SelectRepositoryFragment extends Fragment{
  private String logTag;
  private View rootView;
  
  private PreferenceListener prefListener;
  
  private RequestRepositories thread;
  
  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
    logTag = getResources().getString(R.string.logtag_main);
    rootView = inflater.inflate(R.layout.fragment_select_repository, container, false);
    thread = new RequestRepositories(new RequestListenerAdapter<ArrayList<Repository>>() {
      @Override
      public void whenNoInternetConnection() {
        MainActivity.hasNoInternetConnection(getActivity());
        
      }
      @Override
      public void whenNoSelectedRepository() {
        MainActivity.hasNoSelectedRepository(getActivity());
        
      }
    });
    
    prefListener = new PreferenceListener() {
      @Override
      public void preferenceChanged(PREF_KEY key) {
        switch (key) {
        case USER_REPOSITORIES:
          RadioGroup radioGroup = (RadioGroup) rootView.findViewById(R.id.radiogroup_repos);
          radioGroup.removeAllViews();
          ArrayList<Repository> repoList = Preferences.getRepositories();
          OnClickListener radioButtonListener = new OnClickListener() {
            @Override
            public void onClick(View v) {
              Preferences.removeAllBranches();
              Preferences.setSelectedRepository(new Repository(((RadioButton) v).getText().toString()));
              TemporaryStorage.branchList = null;
              TemporaryStorage.workingFiles = new ArrayList<File>();
              Preferences.setWorkingFiles(new ArrayList<File>());
              Preferences.removeAllBranches();
              ((MainActivity) getActivity()).displayView(VIEW.BRANCHES);
            }
          };
          String selectedRepo = Preferences.getSelectedRepository().getName();
          for(Repository repo : repoList){
            RadioButton button = new RadioButton(rootView.getContext());
            button.setText(repo.getName());
            button.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
            button.setOnClickListener(radioButtonListener);
            radioGroup.addView(button);
            if(repo.getName().equals(selectedRepo)){
              button.setChecked(true);
            }
          }
          break;
        default:
          break;
        }
        
      }
    };
    Preferences.addListener(prefListener);
    
    thread.execute();
        return rootView;
    }
  
  @Override
  public void onDestroy(){
    Preferences.removeListener(prefListener);
    thread.abortRequest(false);
    super.onDestroy();
  }
}




Java Source Code List

se.agile.activities.AboutFragment.java
se.agile.activities.BranchFragment.java
se.agile.activities.BranchesFragment.java
se.agile.activities.CardFragment.java
se.agile.activities.CollaboratorsFragment.java
se.agile.activities.CommitFragment.java
se.agile.activities.ConflictFragment.java
se.agile.activities.ConnectToGitHubFragment.java
se.agile.activities.LoginActivity.java
se.agile.activities.MainActivity.java
se.agile.activities.NotificationFragmentSwitcher.java
se.agile.activities.NotificationsFragment.java
se.agile.activities.PersonalNotesFragment.java
se.agile.activities.PokerFragment.java
se.agile.activities.RepositoryOverviewFragment.java
se.agile.activities.SelectRepositoryFragment.java
se.agile.activities.SelectWorkingFilesActivity.java
se.agile.activities.SelectWorkingFilesFragment.java
se.agile.activities.SelectWorkingFilesOverviewFragment.java
se.agile.activities.SettingsFragment.java
se.agile.activities.SignOutFragment.java
se.agile.asynctasks.RequestAccessToken.java
se.agile.asynctasks.RequestAllCommitsForBranch.java
se.agile.asynctasks.RequestAllFilesForBranch.java
se.agile.asynctasks.RequestBranch.java
se.agile.asynctasks.RequestBranches.java
se.agile.asynctasks.RequestFiles.java
se.agile.asynctasks.RequestFullCommit.java
se.agile.asynctasks.RequestListenerAdapter.java
se.agile.asynctasks.RequestListener.java
se.agile.asynctasks.RequestRepositories.java
se.agile.asynctasks.RequestShortCommit.java
se.agile.asynctasks.RequestTask.java
se.agile.asynctasks.RequestUser.java
se.agile.controller.MainActivityController.java
se.agile.controller.settingsFragmentController.java
se.agile.githubdata.Branch.java
se.agile.githubdata.Commit.java
se.agile.githubdata.Directory.java
se.agile.githubdata.File.java
se.agile.githubdata.Folder.java
se.agile.githubdata.GitHubDataInterface.java
se.agile.githubdata.Repository.java
se.agile.githubdata.User.java
se.agile.model.BranchNotification.java
se.agile.model.BranchSelectionModel.java
se.agile.model.CommitNotification.java
se.agile.model.ConflictNotification.java
se.agile.model.CreateNotificationActivity.java
se.agile.model.DirectoryListArrayAdapter.java
se.agile.model.InteractiveArrayAdapter.java
se.agile.model.JSONParser.java
se.agile.model.NotificationDialog.java
se.agile.model.NotificationHandler.java
se.agile.model.NotificationListArrayAdapter.java
se.agile.model.NotificationListener.java
se.agile.model.Notification.java
se.agile.model.PreferenceListener.java
se.agile.model.Preferences.java
se.agile.model.TemporaryStorage.java
se.agile.model.Tuple.java
se.agile.model.WorkingFileListArrayAdapter.java
se.agile.navigator.NavDrawerItem.java
se.agile.navigator.NavDrawerListAdapter.java