use of android.support.v7.widget.helper.ItemTouchHelper.START in project iosched by google.
the class ExploreSessionsActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.explore_sessions_act);
// Transition will be postponed until header image is loaded
supportPostponeEnterTransition();
mImageLoader = new ImageLoader(this);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mCollapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
mHeaderImage = (ImageView) findViewById(R.id.header_image);
mTitle = (TextView) findViewById(R.id.title);
mFiltersList = (RecyclerView) findViewById(R.id.filters);
mTimeSlotLayout = findViewById(R.id.timeslot_view);
mTimeSlotDivider = findViewById(R.id.timeslot_divider);
TextView timeSlotTextView = (TextView) findViewById(R.id.timeslot);
ImageButton dismissTimeSlotButton = (ImageButton) findViewById(R.id.close_timeslot);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_flipped, GravityCompat.END);
mFragment = (ExploreSessionsFragment) getFragmentManager().findFragmentById(R.id.explore_sessions_frag);
if (savedInstanceState != null) {
mTagFilterHolder = savedInstanceState.getParcelable(STATE_FILTER_TAGS);
mCurrentUri = savedInstanceState.getParcelable(STATE_CURRENT_URI);
} else if (getIntent() != null) {
mCurrentUri = getIntent().getData();
}
// Build the tag URI
long[] interval = ScheduleContract.Sessions.getInterval(mCurrentUri);
if (interval != null) {
mMode = MODE_TIME_FIT;
String title = getString(R.string.explore_sessions_time_slot_title, TimeUtils.getDayName(this, UIUtils.startTimeToDayIndex(interval[0])), UIUtils.formatTime(interval[0], this));
mTitle.setText(title);
mHeaderImage.setScaleType(ImageView.ScaleType.FIT_CENTER);
mHeaderImage.setImageResource(R.drawable.ic_hash_io_16_monochrome);
mTimeSlotLayout.setVisibility(View.VISIBLE);
mTimeSlotDivider.setVisibility(View.VISIBLE);
timeSlotTextView.setText(title);
dismissTimeSlotButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mTimeSlotLayout.setVisibility(View.GONE);
mTimeSlotDivider.setVisibility(View.GONE);
mMode = MODE_EXPLORE;
mCurrentUri = null;
reloadFragment();
}
});
} else {
mMode = MODE_EXPLORE;
}
// Add the back button to the toolbar.
setToolbarAsUp(new View.OnClickListener() {
@Override
public void onClick(View view) {
navigateUpOrBack(ExploreSessionsActivity.this, null);
}
});
getSupportActionBar().setDisplayShowTitleEnabled(false);
// Start loading the tag metadata. This will in turn call the fragment with the
// correct arguments.
getLoaderManager().initLoader(TAG_METADATA_TOKEN, null, this);
// ANALYTICS SCREEN: View the Explore Sessions screen
// Contains: Nothing (Page name is a constant)
AnalyticsHelper.sendScreenView(SCREEN_LABEL);
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project material-components-android by material-components.
the class NavigationViewTest method testHeaders.
@Test
public void testHeaders() {
// Open our drawer
onView(withId(R.id.drawer_layout)).perform(openDrawer(GravityCompat.START));
// We should have no headers at the start
verifyHeaders();
// Inflate one header and check that it's there in the navigation view
onView(withId(R.id.start_drawer)).perform(inflateHeaderView(R.layout.design_navigation_view_header1));
verifyHeaders(R.id.header1);
final LayoutInflater inflater = LayoutInflater.from(activityTestRule.getActivity());
// Add one more header and check that it's there in the navigation view
onView(withId(R.id.start_drawer)).perform(addHeaderView(inflater, R.layout.design_navigation_view_header2));
verifyHeaders(R.id.header1, R.id.header2);
final View header1 = mNavigationView.findViewById(R.id.header1);
// Remove the first header and check that we still have the second header
onView(withId(R.id.start_drawer)).perform(removeHeaderView(header1));
verifyHeaders(R.id.header2);
// Add one more header and check that we now have two headers
onView(withId(R.id.start_drawer)).perform(inflateHeaderView(R.layout.design_navigation_view_header3));
verifyHeaders(R.id.header2, R.id.header3);
// Add another "copy" of the header from the just-added layout and check that we now
// have three headers
onView(withId(R.id.start_drawer)).perform(addHeaderView(inflater, R.layout.design_navigation_view_header3));
verifyHeaders(R.id.header2, R.id.header3, R.id.header3);
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project xabber-android by redsolution.
the class ChatViewerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.chat_viewer_fragment, container, false);
contactTitleView = view.findViewById(R.id.contact_title);
abstractContact = RosterManager.getInstance().getBestContact(account, user);
contactTitleView.findViewById(R.id.avatar).setOnClickListener(this);
toolbar = (Toolbar) view.findViewById(R.id.toolbar_default);
toolbar.inflateMenu(R.menu.chat);
toolbar.setOnMenuItemClickListener(this);
toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NavUtils.navigateUpFromSameTask(getActivity());
}
});
setHasOptionsMenu(true);
sendButton = (ImageButton) view.findViewById(R.id.button_send_message);
sendButton.setColorFilter(ColorManager.getInstance().getAccountPainter().getGreyMain());
AbstractChat abstractChat = MessageManager.getInstance().getChat(account, user);
securityButton = (ImageButton) view.findViewById(R.id.button_security);
if (abstractChat instanceof RegularChat) {
securityButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showSecurityMenu();
}
});
} else {
securityButton.setVisibility(View.GONE);
}
chatMessageAdapter = new ChatMessageAdapter(getActivity(), account, user, this, this);
recyclerView = (RecyclerView) view.findViewById(R.id.chat_messages_recycler_view);
recyclerView.setAdapter(chatMessageAdapter);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager);
// to avoid strange bug on some 4.x androids
view.findViewById(R.id.input_layout).setBackgroundColor(ColorManager.getInstance().getChatInputBackgroundColor());
inputView = (EditText) view.findViewById(R.id.chat_input);
view.findViewById(R.id.button_send_message).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendMessage();
}
});
inputView.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int keyCode, KeyEvent event) {
if (SettingsManager.chatsSendByEnter() && event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {
sendMessage();
return true;
}
return false;
}
});
inputView.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (!skipOnTextChanges && stopTypingTimer != null) {
stopTypingTimer.cancel();
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable text) {
setUpInputViewButtons();
if (skipOnTextChanges) {
return;
}
ChatStateManager.getInstance().onComposing(account, user, text);
stopTypingTimer = new Timer();
stopTypingTimer.schedule(new TimerTask() {
@Override
public void run() {
Application.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
ChatStateManager.getInstance().onPaused(account, user);
}
});
}
}, STOP_TYPING_DELAY);
}
});
final ImageButton emojiButton = (ImageButton) view.findViewById(R.id.button_emoticon);
final View rootView = view.findViewById(R.id.root_view);
// Give the topmost view of your activity layout hierarchy. This will be used to measure soft keyboard height
final EmojiconsPopup popup = new EmojiconsPopup(rootView, getActivity());
//Will automatically set size according to the soft keyboard size
popup.setSizeForSoftKeyboard();
//If the emoji popup is dismissed, change emojiButton to smiley icon
popup.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_mood_black_24dp);
}
});
//If the text keyboard closes, also dismiss the emoji popup
popup.setOnSoftKeyboardOpenCloseListener(new EmojiconsPopup.OnSoftKeyboardOpenCloseListener() {
@Override
public void onKeyboardOpen(int keyBoardHeight) {
}
@Override
public void onKeyboardClose() {
if (popup.isShowing())
popup.dismiss();
}
});
//On emoji clicked, add it to edittext
popup.setOnEmojiconClickedListener(new EmojiconGridView.OnEmojiconClickedListener() {
@Override
public void onEmojiconClicked(Emojicon emojicon) {
if (inputView == null || emojicon == null) {
return;
}
int start = inputView.getSelectionStart();
int end = inputView.getSelectionEnd();
if (start < 0) {
inputView.append(emojicon.getEmoji());
} else {
inputView.getText().replace(Math.min(start, end), Math.max(start, end), emojicon.getEmoji(), 0, emojicon.getEmoji().length());
}
}
});
//On backspace clicked, emulate the KEYCODE_DEL key event
popup.setOnEmojiconBackspaceClickedListener(new EmojiconsPopup.OnEmojiconBackspaceClickedListener() {
@Override
public void onEmojiconBackspaceClicked(View v) {
KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
inputView.dispatchKeyEvent(event);
}
});
// To toggle between text keyboard and emoji keyboard keyboard(Popup)
emojiButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//If popup is not showing => emoji keyboard is not visible, we need to show it
if (!popup.isShowing()) {
//If keyboard is visible, simply show the emoji popup
if (popup.isKeyBoardOpen()) {
popup.showAtBottom();
changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_keyboard_black_24dp);
} else //else, open the text keyboard first and immediately after that show the emoji popup
{
inputView.setFocusableInTouchMode(true);
inputView.requestFocus();
popup.showAtBottomPending();
final InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(inputView, InputMethodManager.SHOW_IMPLICIT);
changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_keyboard_black_24dp);
}
} else //If popup is showing, simply dismiss it to show the undelying text keyboard
{
popup.dismiss();
}
}
});
attachButton = (ImageButton) view.findViewById(R.id.button_attach);
attachButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onAttachButtonPressed();
}
});
return view;
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project LookLook by xinghongfei.
the class MainActivity method animateToolbar.
private void animateToolbar() {
// this is gross but toolbar doesn't expose it's children to animate them :(
View t = toolbar.getChildAt(0);
if (t != null && t instanceof TextView) {
TextView title = (TextView) t;
// fade in and space out the title. Animating the letterSpacing performs horribly so
// fake it by setting the desired letterSpacing then animating the scaleX ¯\_(ツ)_/¯
title.setAlpha(0f);
title.setScaleX(0.8f);
title.animate().alpha(1f).scaleX(1f).setStartDelay(500).setDuration(900).setInterpolator(AnimUtils.getFastOutSlowInInterpolator(this)).start();
}
View amv = toolbar.getChildAt(1);
if (amv != null & amv instanceof ActionMenuView) {
ActionMenuView actions = (ActionMenuView) amv;
// filter
popAnim(actions.getChildAt(0), 500, 200);
// overflow
popAnim(actions.getChildAt(1), 700, 200);
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project android by owncloud.
the class LocalFolderPickerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
Log_OC.d(TAG, "onCreate() start");
super.onCreate(savedInstanceState);
// set current folder
String startPath = (savedInstanceState != null) ? savedInstanceState.getString(LocalFolderPickerActivity.EXTRA_PATH) : getIntent().getStringExtra(EXTRA_PATH);
if (startPath != null) {
mCurrentFolder = new File(startPath);
}
if (mCurrentFolder == null || !mCurrentFolder.exists()) {
// default
mCurrentFolder = Environment.getExternalStorageDirectory();
} else if (!mCurrentFolder.isDirectory()) {
mCurrentFolder = mCurrentFolder.getParentFile();
}
// inflate and set the layout view
// beware - inflated in other activities too
setContentView(R.layout.files_folder_picker);
if (savedInstanceState == null) {
createFragments();
}
// set input controllers
mCancelBtn = (Button) findViewById(R.id.folder_picker_btn_cancel);
mCancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setResult(RESULT_CANCELED);
finish();
}
});
mChooseBtn = (Button) findViewById(R.id.folder_picker_btn_choose);
mChooseBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// return the path of the current folder
Intent data = new Intent();
data.putExtra(EXTRA_PATH, mCurrentFolder.getAbsolutePath());
setResult(RESULT_OK, data);
finish();
}
});
// init toolbar
setupToolbar();
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(true);
}
updateActionBar();
Log_OC.d(TAG, "onCreate() end");
}
Aggregations