use of android.widget.AdapterView in project Hummingbird-for-Android by xiprox.
the class AnimeDetailsActivity method displayLibraryElements.
/* If Anime exist in user library, show library related elements... */
public void displayLibraryElements() {
if (libraryEntry != null) {
if (mRemove != null)
mRemove.setVisible(true);
final String animeEpisodeCount = anime.getEpisodeCount() != 0 ? anime.getEpisodeCount() + "" : "?";
mEpisodes.setText(libraryEntry.getEpisodesWatched() + "/" + animeEpisodeCount);
mRewatching.setChecked(libraryEntry.isRewatching());
mRewatchedTimes.setText(libraryEntry.getNumberOfRewatches() + "");
mPrivate.setChecked(libraryEntry.isPrivate());
Rating rating = libraryEntry.getRating();
if (rating.isAdvanced()) {
if (rating.getAdvancedRating() != null)
mRatingBar.setRating(Float.parseFloat(rating.getAdvancedRating()));
else
mRatingBar.setRating(0);
mRatingBar.setVisibility(View.VISIBLE);
mSimpleRatingView.setVisibility(View.GONE);
} else {
if (rating.getSimpleRating() != null)
mSimpleRatingView.setSelectedRating(Utils.getRatingFromString(rating.getSimpleRating()));
else
mSimpleRatingView.setSelectedRating(SimpleRatingView.Rating.NEUTRAL);
mRatingBar.setVisibility(View.GONE);
mSimpleRatingView.setVisibility(View.VISIBLE);
}
newWatchStatus = libraryEntry.getStatus();
newEpisodesWatched = libraryEntry.getEpisodesWatched();
newIsRewatching = libraryEntry.isRewatching();
newRewatchedTimes = libraryEntry.getNumberOfRewatches();
newPrivate = libraryEntry.isPrivate();
newRating = libraryEntry.getRating().getAdvancedRating() != null ? libraryEntry.getRating().getAdvancedRating() : "0";
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(AnimeDetailsActivity.this, R.array.library_watch_status_items, R.layout.item_spinner_library_status);
adapter.setDropDownViewResource(R.layout.item_spinner_item_library_status);
mStatusSpinner.setAdapter(adapter);
String watchStatus = libraryEntry.getStatus();
if (watchStatus.equals("currently-watching"))
mStatusSpinner.setSelection(0);
if (watchStatus.equals("plan-to-watch"))
mStatusSpinner.setSelection(1);
if (watchStatus.equals("completed"))
mStatusSpinner.setSelection(2);
if (watchStatus.equals("on-hold"))
mStatusSpinner.setSelection(3);
if (watchStatus.equals("dropped"))
mStatusSpinner.setSelection(4);
mEpisodesHolder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
View dialogView = getLayoutInflater().inflate(R.layout.number_picker, null);
final NumberPicker mNumberPicker = (NumberPicker) dialogView.findViewById(R.id.number_picker);
mNumberPicker.setMaxValue(anime.getEpisodeCount() != 0 ? anime.getEpisodeCount() : 1000);
mNumberPicker.setValue(newEpisodesWatched);
mNumberPicker.setWrapSelectorWheel(false);
new MaterialDialog.Builder(AnimeDetailsActivity.this).title(R.string.content_episodes).positiveText(R.string.ok).negativeText(R.string.cancel).positiveColor(vibrantColor).negativeColorRes(R.color.text_dialog_action).customView(dialogView, true).callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog materialDialog) {
newEpisodesWatched = mNumberPicker.getValue();
mEpisodes.setText(newEpisodesWatched + "/" + animeEpisodeCount);
if ((newEpisodesWatched + "").equals(animeEpisodeCount))
// (completed)
mStatusSpinner.setSelection(2);
updateUpdateButtonStatus(libraryEntry);
}
}).show();
}
});
mRewatching.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
newIsRewatching = isChecked;
updateUpdateButtonStatus(libraryEntry);
}
});
mRewatchedTimesHolder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
View dialogView = getLayoutInflater().inflate(R.layout.number_picker, null);
final NumberPicker mNumberPicker = (NumberPicker) dialogView.findViewById(R.id.number_picker);
mNumberPicker.setMaxValue(200);
mNumberPicker.setValue(newRewatchedTimes);
mNumberPicker.setWrapSelectorWheel(false);
new MaterialDialog.Builder(AnimeDetailsActivity.this).title(R.string.content_rewatched).positiveText(R.string.ok).negativeText(R.string.cancel).positiveColor(vibrantColor).negativeColorRes(R.color.text_dialog_action).customView(dialogView, true).callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog materialDialog) {
newRewatchedTimes = mNumberPicker.getValue();
mRewatchedTimes.setText(newRewatchedTimes + "");
updateUpdateButtonStatus(libraryEntry);
}
}).show();
}
});
mPrivate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
newPrivate = isChecked;
updateUpdateButtonStatus(libraryEntry);
}
});
mStatusSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
switch(position) {
case 0:
newWatchStatus = "currently-watching";
break;
case 1:
newWatchStatus = "plan-to-watch";
break;
case 2:
newWatchStatus = "completed";
break;
case 3:
newWatchStatus = "on-hold";
break;
case 4:
newWatchStatus = "dropped";
break;
}
updateUpdateButtonStatus(libraryEntry);
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
mRatingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
newRating = rating + "";
updateUpdateButtonStatus(libraryEntry);
}
});
mSimpleRatingView.setOnRatingChangedListener(new SimpleRatingView.OnRatingChangeListener() {
@Override
public void onRatingChanged(SimpleRatingView.Rating rating) {
switch(rating) {
case POSITIVE:
newRating = "1";
break;
case NEUTRAL:
newRating = "3";
break;
case NEGATIVE:
newRating = "5";
break;
}
updateUpdateButtonStatus(libraryEntry);
}
});
mActionButton.setImageResource(R.drawable.ic_upload_white_24dp);
mActionButton.setOnClickListener(new OnLibraryUpdateClickListener());
mLibraryProgressBar.setVisibility(View.GONE);
mLibraryInfoHolder.setVisibility(View.VISIBLE);
} else {
enableFAB();
mRemove.setVisible(false);
mLibraryProgressBar.setVisibility(View.GONE);
mLibraryInfoHolder.setVisibility(View.GONE);
}
}
use of android.widget.AdapterView in project XobotOS by xamarin.
the class ChooseAccountActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAccounts = getIntent().getParcelableArrayExtra(AccountManager.KEY_ACCOUNTS);
mAccountManagerResponse = getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_MANAGER_RESPONSE);
// KEY_ACCOUNTS is a required parameter
if (mAccounts == null) {
setResult(RESULT_CANCELED);
finish();
return;
}
getAuthDescriptions();
AccountInfo[] mAccountInfos = new AccountInfo[mAccounts.length];
for (int i = 0; i < mAccounts.length; i++) {
mAccountInfos[i] = new AccountInfo(((Account) mAccounts[i]).name, getDrawableForType(((Account) mAccounts[i]).type));
}
setContentView(R.layout.choose_account);
// Setup the list
ListView list = (ListView) findViewById(android.R.id.list);
// Use an existing ListAdapter that will map an array of strings to TextViews
list.setAdapter(new AccountArrayAdapter(this, android.R.layout.simple_list_item_1, mAccountInfos));
list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
list.setTextFilterEnabled(true);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
onListItemClick((ListView) parent, v, position, id);
}
});
}
use of android.widget.AdapterView in project PLDroidPlayer by pili-engineering.
the class VideoFileActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_file);
mVideoListView = (ListView) findViewById(R.id.FileListView);
mVideoAdapter = new VideoAdapter(this);
mVideoListView.setAdapter(mVideoAdapter);
mVideoListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, final long id) {
Intent intent = new Intent();
intent.putExtra("videoPath", mVideoAdapter.getVideoPath(position));
setResult(Activity.RESULT_OK, intent);
finish();
}
});
getSupportLoaderManager().initLoader(1, null, this);
}
use of android.widget.AdapterView in project PocketHub by pockethub.
the class ItemListFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_item);
swipeLayout.setOnRefreshListener(this);
swipeLayout.setColorSchemeResources(R.color.pager_title_background_top_start, R.color.pager_title_background_end, R.color.text_link, R.color.pager_title_background_end);
listView = (ListView) view.findViewById(android.R.id.list);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
onListItemClick((ListView) parent, view, position, id);
}
});
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
return onListItemLongClick((ListView) parent, view, position, id);
}
});
progressBar = (ProgressBar) view.findViewById(R.id.pb_loading);
emptyView = (TextView) view.findViewById(android.R.id.empty);
configureList(getActivity(), getListView());
}
use of android.widget.AdapterView in project carat by amplab.
the class BugsOrHogsFragment method initEnergyDetails.
private void initEnergyDetails(View root, ViewGroup container) {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
detailPage = inflater.inflate(R.layout.graph, container);
w = new DrawView(getActivity());
OnClickListener detailViewer = new OnClickListener() {
@Override
public void onClick(View arg0) {
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getActivity());
if (p != null) {
String uuId = p.getString(CaratApplication.getRegisteredUuid(), "UNKNOWN");
HashMap<String, String> options = new HashMap<String, String>();
options.put("status", getActivity().getTitle().toString());
options.put("type", isBugs ? "Bugs" : "Hogs");
options.put("app", ((TextView) detailPage.findViewById(R.id.name)).getText() + "");
options.put("benefit", ((TextView) detailPage.findViewById(R.id.benefit)).getText().toString().replace('±', '+'));
ClickTracking.track(uuId, "whatnumbers", options, getActivity());
}
}
};
View moreinfo = detailPage.findViewById(R.id.jscore_info);
moreinfo.setOnClickListener(detailViewer);
View item = detailPage.findViewById(R.id.benefit);
item.setClickable(true);
item.setOnClickListener(detailViewer);
item = detailPage.findViewById(R.id.benefit);
item.setClickable(true);
item.setOnClickListener(detailViewer);
item = detailPage.findViewById(R.id.name);
item.setClickable(true);
item.setOnClickListener(detailViewer);
item = detailPage.findViewById(R.id.appIcon);
item.setClickable(true);
item.setOnClickListener(detailViewer);
final ListView lv = (ListView) root.findViewById(android.R.id.list);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Object o = lv.getItemAtPosition(position);
SimpleHogBug fullObject = (SimpleHogBug) o;
AppDetailsFragment fragment = AppDetailsFragment.getInstance(Constants.Type.BUG, fullObject, isBugs);
CaratApplication.getMainActivity().replaceFragment(fragment, fullObject.getAppName(), false);
}
});
}
Aggregations