List of usage examples for android.os Bundle getSerializable
@Override
@Nullable
public Serializable getSerializable(@Nullable String key)
From source file:com.example.reedme.date.DatePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(TAG, "onCreateView: "); // All options have been set at this point: round the initial selection if necessary setToNearestDate(mCalendar);//w ww . j av a2 s . com View view = inflater.inflate(R.layout.mdtp_date_picker_dialog, container, false); mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header); mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day); mMonthAndDayView.setOnClickListener(this); mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month); mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day); mYearView = (TextView) view.findViewById(R.id.date_picker_year); mYearView.setOnClickListener(this); int listPosition = -1; int listPositionOffset = 0; int currentView = mDefaultView; if (savedInstanceState != null) { mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); mMinYear = savedInstanceState.getInt(KEY_YEAR_START); mMaxYear = savedInstanceState.getInt(KEY_YEAR_END); currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW); listPosition = savedInstanceState.getInt(KEY_LIST_POSITION); listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET); mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE); mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE); highlightedDays = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS); selectableDays = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS); mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK); mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED); mAccentColor = savedInstanceState.getInt(KEY_ACCENT); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS); mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS); mTitle = savedInstanceState.getString(KEY_TITLE); mOkResid = savedInstanceState.getInt(KEY_OK_RESID); mOkString = savedInstanceState.getString(KEY_OK_STRING); mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID); mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING); } final Activity activity = getActivity(); mDayPickerView = new SimpleDayPickerView(activity, this); mYearPickerView = new YearPickerView(activity, this); // if theme mode has not been set by java code, check if it is specified in Style.xml if (!mThemeDarkChanged) { mThemeDark = Util.isDarkTheme(activity, mThemeDark); } Resources res = getResources(); mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description); mSelectDay = res.getString(R.string.mdtp_select_day); mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description); mSelectYear = res.getString(R.string.mdtp_select_year); int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme : R.color.mdtp_date_picker_view_animator; view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource)); mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator); mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.setDateMillis(mCalendar.getTimeInMillis()); // TODO: Replace with animation decided upon by the design team. Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); // TODO: Replace with animation decided upon by the design team. Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); Button okButton = (Button) view.findViewById(R.id.ok); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); notifyOnDateListener(); dismiss(); } }); okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mOkString != null) okButton.setText(mOkString); else okButton.setText(mOkResid); Button cancelButton = (Button) view.findViewById(R.id.cancel); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mCancelString != null) cancelButton.setText(mCancelString); else cancelButton.setText(mCancelResid); cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Util.getAccentColorFromThemeIfAvailable(getActivity()); } if (mDayOfWeekView != null) mDayOfWeekView.setBackgroundColor(Util.darkenColor(mAccentColor)); view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor); okButton.setTextColor(mAccentColor); cancelButton.setTextColor(mAccentColor); if (getDialog() == null) { view.findViewById(R.id.done_background).setVisibility(View.GONE); } updateDisplay(false); setCurrentView(currentView); if (listPosition != -1) { if (currentView == MONTH_AND_DAY_VIEW) { mDayPickerView.postSetSelection(listPosition); } else if (currentView == YEAR_VIEW) { mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset); } } mHapticFeedbackController = new HapticFeedbackController(activity); return view; }
From source file:com.irccloud.android.activity.UploadsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (ColorFormatter.file_uri_template != null) template = UriTemplate.fromTemplate(ColorFormatter.file_uri_template); super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC));/*from ww w. j a va 2s .com*/ cloud.recycle(); } if (Build.VERSION.SDK_INT >= 14) { try { java.io.File httpCacheDir = new java.io.File(getCacheDir(), "http"); long httpCacheSize = 10 * 1024 * 1024; // 10 MiB HttpResponseCache.install(httpCacheDir, httpCacheSize); } catch (IOException e) { Log.i("IRCCloud", "HTTP response cache installation failed:" + e); } } setContentView(R.layout.ignorelist); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar)); getSupportActionBar().setElevation(0); } if (savedInstanceState != null && savedInstanceState.containsKey("cid")) { cid = savedInstanceState.getInt("cid"); to = savedInstanceState.getString("to"); msg = savedInstanceState.getString("msg"); page = savedInstanceState.getInt("page"); File[] files = (File[]) savedInstanceState.getSerializable("adapter"); for (File f : files) { adapter.addFile(f); } adapter.notifyDataSetChanged(); } footer = getLayoutInflater().inflate(R.layout.messageview_header, null); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(adapter); listView.addFooterView(footer); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) { canLoadMore = false; new FetchFilesTask().execute((Void) null); } } }); listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { final File f = (File) adapter.getItem(i); AlertDialog.Builder builder = new AlertDialog.Builder(UploadsActivity.this); builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB); final View v = getLayoutInflater().inflate(R.layout.dialog_upload, null); final EditText messageinput = (EditText) v.findViewById(R.id.message); messageinput.setText(msg); final ImageView thumbnail = (ImageView) v.findViewById(R.id.thumbnail); v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (messageinput.hasFocus()) { v.post(new Runnable() { @Override public void run() { v.scrollTo(0, v.getBottom()); } }); } } }); if (f.mime_type.startsWith("image/")) { try { thumbnail.setImageBitmap(f.image); thumbnail.setVisibility(View.VISIBLE); thumbnail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(UploadsActivity.this, ImageViewerActivity.class); i.setData(Uri.parse(f.url)); startActivity(i); } }); thumbnail.setClickable(true); } catch (Exception e) { e.printStackTrace(); } } else { thumbnail.setVisibility(View.GONE); } ((TextView) v.findViewById(R.id.filesize)).setText(f.metadata); v.findViewById(R.id.filename).setVisibility(View.GONE); v.findViewById(R.id.filename_heading).setVisibility(View.GONE); builder.setTitle("Send A File To " + to); builder.setView(v); builder.setPositiveButton("Send", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String message = messageinput.getText().toString(); if (message.length() > 0) message += " "; message += f.url; dialog.dismiss(); if (getParent() == null) { setResult(Activity.RESULT_OK); } else { getParent().setResult(Activity.RESULT_OK); } finish(); NetworkConnection.getInstance().say(cid, to, message); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog d = builder.create(); d.setOwnerActivity(UploadsActivity.this); d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); d.show(); } }); }
From source file:com.layernet.thaidatetimepicker.date.DatePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // All options have been set at this point: round the initial selection if necessary setToNearestDate(mCalendar);/*from w w w . j a v a 2 s . c om*/ View view = inflater.inflate(R.layout.mdtp_date_picker_dialog, container, false); mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header); mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day); mMonthAndDayView.setOnClickListener(this); mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month); mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day); mYearView = (TextView) view.findViewById(R.id.date_picker_year); mYearView.setOnClickListener(this); int listPosition = -1; int listPositionOffset = 0; int currentView = mDefaultView; if (savedInstanceState != null) { mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); mMinYear = savedInstanceState.getInt(KEY_YEAR_START); mMaxYear = savedInstanceState.getInt(KEY_YEAR_END); currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW); listPosition = savedInstanceState.getInt(KEY_LIST_POSITION); listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET); mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE); mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE); highlightedDays = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS); selectableDays = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS); disabledDays = (Calendar[]) savedInstanceState.getSerializable(KEY_DISABLED_DAYS); mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK); mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED); mAccentColor = savedInstanceState.getInt(KEY_ACCENT); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS); mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS); mTitle = savedInstanceState.getString(KEY_TITLE); mOkResid = savedInstanceState.getInt(KEY_OK_RESID); mOkString = savedInstanceState.getString(KEY_OK_STRING); mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID); mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING); } final Activity activity = getActivity(); mDayPickerView = new SimpleDayPickerView(activity, this); mYearPickerView = new YearPickerView(activity, this); // if theme mode has not been set by java code, check if it is specified in Style.xml if (!mThemeDarkChanged) { mThemeDark = Utils.isDarkTheme(activity, mThemeDark); } Resources res = getResources(); mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description); mSelectDay = res.getString(R.string.mdtp_select_day); mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description); mSelectYear = res.getString(R.string.mdtp_select_year); int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme : R.color.mdtp_date_picker_view_animator; view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource)); mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator); mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.setDateMillis(mCalendar.getTimeInMillis()); // TODO: Replace with animation decided upon by the design team. Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); // TODO: Replace with animation decided upon by the design team. Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); Button okButton = (Button) view.findViewById(R.id.ok); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); notifyOnDateListener(); dismiss(); } }); okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mOkString != null) okButton.setText(mOkString); else okButton.setText(mOkResid); Button cancelButton = (Button) view.findViewById(R.id.cancel); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mCancelString != null) cancelButton.setText(mCancelString); else cancelButton.setText(mCancelResid); cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); } if (mDayOfWeekView != null) mDayOfWeekView.setBackgroundColor(Utils.darkenColor(mAccentColor)); view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor); okButton.setTextColor(mAccentColor); cancelButton.setTextColor(mAccentColor); if (getDialog() == null) { view.findViewById(R.id.done_background).setVisibility(View.GONE); } updateDisplay(false); setCurrentView(currentView); if (listPosition != -1) { if (currentView == MONTH_AND_DAY_VIEW) { mDayPickerView.postSetSelection(listPosition); } else if (currentView == YEAR_VIEW) { mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset); } } mHapticFeedbackController = new HapticFeedbackController(activity); return view; }
From source file:com.free.searcher.MainFragment.java
@Override public void onViewStateRestored(Bundle savedInstanceState) { super.onViewStateRestored(savedInstanceState); if (savedInstanceState == null) { return;/*from w ww. ja va2 s .c om*/ } Log.i("SearcheFragment.onViewStateRestored();", savedInstanceState + "uuu"); selectedFiles = savedInstanceState.getStringArray("selectedFiles"); if (savedInstanceState.getSerializable("files") instanceof File[]) { files = (File[]) savedInstanceState.getSerializable("files"); } if (savedInstanceState.getString("currentSearching") instanceof String) { currentSearching = savedInstanceState.getString("currentSearching"); } if (savedInstanceState.getString("currentZipFileName") instanceof String) { currentZipFileName = savedInstanceState.getString("currentZipFileName"); if (currentZipFileName.length() > 0) { try { extractFile = new ExtractFile(currentZipFileName, MainFragment.PRIVATE_PATH + currentZipFileName); } catch (RarException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } if (savedInstanceState.getString("load") instanceof String) { load = savedInstanceState.getString("load"); } if (savedInstanceState.getString("currentUrl") instanceof String) { currentUrl = savedInstanceState.getString("currentUrl"); } // HtmlSourceViewJavaScriptInterface.source = savedInstanceState.getString("source"); if (currentUrl != null && currentUrl.length() > 0) { (webTask = new WebTask(MainFragment.this, webView, currentUrl)).execute(); } if (mSearchView != null && savedInstanceState.getCharSequence("query") != null) { mSearchView.setQuery(savedInstanceState.getCharSequence("query"), false); } if (savedInstanceState.getString("status") instanceof String) { status = savedInstanceState.getCharSequence("status"); } locX = savedInstanceState.getInt("locX"); locY = savedInstanceState.getInt("locY"); webViewBundle = savedInstanceState.getBundle("webViewBundle"); if (savedInstanceState.getString("home") instanceof String) { home = savedInstanceState.getString("home"); } // webView.setOnTouchListener(new View.OnTouchListener() { // @Override // public boolean onTouch(View p1, MotionEvent event) { // //Log.d("onClick", p1 + ""); // Log.d("MotionEvent", event + ""); // if ((event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_POINTER_UP) && statusView != null) { // int curVis = statusView.getSystemUiVisibility(); // Log.d("curVis", curVis + ", " + ((curVis&View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0)); // SHOW = !SHOW; // Log.d("SHOW", SHOW + ""); // setNavVisibility(SHOW); //((curVis&View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0); // } // return false; // } // }); /** if (savedInstanceState.getString("readTextFiles") != null) { String[] readTextFilesStr = savedInstanceState.getString("readTextFiles").split(";;;"); // , // Util.listToString(readTextFiles,false, ";;;")); for (String textFile : readTextFilesStr) { readTextFiles.add(new File(textFile)); } } if (savedInstanceState.getString("initFolderFiles") != null) { String[] initFolderFilesStr = savedInstanceState.getString("initFolderFiles").split(";;;"); // , // Util.listToString(initFolderFiles,false, ";;;")); for (String folderFile : initFolderFilesStr) { initFolderFiles.add(new File(folderFile)); } } **/ }
From source file:de.grobox.transportr.departures.DeparturesActivity.java
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();// w w w . j a va 2 s .com location = (WrapLocation) intent.getSerializableExtra(WRAP_LOCATION); if (location == null || location.getLocation() == null) throw new IllegalArgumentException("No Location"); setContentView(R.layout.activity_departures); // Toolbar Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setSubtitle(location.getName()); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } // Swipe to Refresh swipe = findViewById(R.id.swipe); swipe.setColorSchemeResources(R.color.accent); swipe.setDirection(SwipyRefreshLayoutDirection.BOTH); swipe.setDistanceToTriggerSync(getDragDistance(this)); swipe.setOnRefreshListener(direction -> loadMoreDepartures(direction != TOP)); swipe.setEnabled(false); // Departures List adapter = new DepartureAdapter(); list = findViewById(R.id.list); list.setVisibility(INVISIBLE); list.setAdapter(adapter); list.setLayoutManager(new LinearLayoutManager(this)); // Loader Bundle args = getBundle(location.getId(), new Date(), MAX_DEPARTURES); Loader<QueryDeparturesResult> loader = getSupportLoaderManager().initLoader(LOADER_DEPARTURES, args, this); // Progress Bar and Error View progressBar = findViewById(R.id.progressBar); errorLayout = findViewById(R.id.errorLayout); errorText = errorLayout.findViewById(R.id.errorText); errorLayout.findViewById(R.id.errorButton).setOnClickListener(view -> { LceAnimator.showLoading(progressBar, list, errorLayout); getSupportLoaderManager().restartLoader(LOADER_DEPARTURES, args, this).forceLoad(); }); if (loader.isReset()) { LceAnimator.showLoading(progressBar, list, errorLayout); loader.forceLoad(); } if (savedInstanceState != null) { calendar = (Calendar) savedInstanceState.getSerializable(DATE); // re-attach fragment listener List<Fragment> fragments = getSupportFragmentManager().getFragments(); if (fragments != null && fragments.size() > 0 && fragments.get(0) instanceof TimeDateFragment) { ((TimeDateFragment) fragments.get(0)).setTimeDateListener(this); } } }
From source file:com.gh4a.activities.IssueEditActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!Gh4Application.get().isAuthorized()) { Intent intent = new Intent(this, Github4AndroidActivity.class); startActivity(intent);// w ww. j a va 2 s . c o m finish(); return; } setContentView(R.layout.issue_create); setToolbarScrollable(false); LayoutInflater headerInflater = LayoutInflater.from(UiUtils.makeHeaderThemedContext(this)); View header = headerInflater.inflate(R.layout.issue_create_header, null); addHeaderView(header, false); mTitleWrapper = (TextInputLayout) header.findViewById(R.id.title_wrapper); mTitleView = (EditText) header.findViewById(R.id.et_title); mDescWrapper = (TextInputLayout) header.findViewById(R.id.desc_wrapper); mDescView = (EditText) header.findViewById(R.id.et_desc); CoordinatorLayout rootLayout = getRootLayout(); FloatingActionButton fab = (FloatingActionButton) getLayoutInflater().inflate(R.layout.accept_fab, rootLayout, false); fab.setOnClickListener(this); rootLayout.addView(fab); findViewById(R.id.milestone_container).setOnClickListener(this); findViewById(R.id.assignee_container).setOnClickListener(this); findViewById(R.id.label_container).setOnClickListener(this); mTvSelectedMilestone = (TextView) findViewById(R.id.tv_milestone); mTvSelectedAssignee = (TextView) findViewById(R.id.tv_assignee); mTvLabels = (TextView) findViewById(R.id.tv_labels); mMilestoneContainer = findViewById(R.id.milestone_container); mAssigneeContainer = findViewById(R.id.assignee_container); mLabelContainer = findViewById(R.id.label_container); getSupportLoaderManager().initLoader(3, null, mIsCollaboratorCallback); if (savedInstanceState != null && savedInstanceState.containsKey(STATE_KEY_ISSUE)) { mEditIssue = (Issue) savedInstanceState.getSerializable(STATE_KEY_ISSUE); } else if (!isInEditMode()) { getSupportLoaderManager().initLoader(4, null, mIssueTemplateCallback); mDescView.setEnabled(false); mDescWrapper.setHint(getString(R.string.issue_loading_template_hint)); } if (mEditIssue == null) { mEditIssue = new Issue(); } mTitleView.setText(mEditIssue.getTitle()); mDescView.setText(mEditIssue.getBody()); mTitleView.addTextChangedListener(new UiUtils.ButtonEnableTextWatcher(mTitleView, fab)); mTitleView.addTextChangedListener(new UiUtils.EmptinessWatchingTextWatcher(mTitleView) { @Override public void onIsEmpty(boolean isEmpty) { if (isEmpty) { mTitleWrapper.setError(getString(R.string.issue_error_title)); } else { mTitleWrapper.setErrorEnabled(false); } } }); ActionBar actionBar = getSupportActionBar(); actionBar.setTitle(isInEditMode() ? getString(R.string.issue_edit_title, mEditIssue.getNumber()) : getString(R.string.issue_create)); actionBar.setSubtitle(mRepoOwner + "/" + mRepoName); actionBar.setDisplayHomeAsUpEnabled(true); updateLabels(); updateLabelStates(); setToolbarScrollable(false); }
From source file:com.jarklee.materialdatetimepicker.date.DatePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // All options have been set at this point: round the initial selection if necessary setToNearestDate(mCalendar);/* w ww.jav a 2s . c o m*/ View view = inflater.inflate(R.layout.mdtp_date_picker_dialog, container, false); mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header); mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day); mMonthAndDayView.setOnClickListener(this); mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month); mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day); mYearView = (TextView) view.findViewById(R.id.date_picker_year); mYearView.setOnClickListener(this); int listPosition = -1; int listPositionOffset = 0; int currentView = mDefaultView; if (savedInstanceState != null) { mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); mMinYear = savedInstanceState.getInt(KEY_YEAR_START); mMaxYear = savedInstanceState.getInt(KEY_YEAR_END); currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW); listPosition = savedInstanceState.getInt(KEY_LIST_POSITION); listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET); mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE); mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE); highlightedDays = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS); selectableDays = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS); disabledDays = (Calendar[]) savedInstanceState.getSerializable(KEY_DISABLED_DAYS); mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK); mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED); mAccentColor = savedInstanceState.getInt(KEY_ACCENT); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS); mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS); mTitle = savedInstanceState.getString(KEY_TITLE); mOkResid = savedInstanceState.getInt(KEY_OK_RESID); mOkString = savedInstanceState.getString(KEY_OK_STRING); mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID); mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING); } final Activity activity = getActivity(); mDayPickerView = new SimpleDayPickerView(activity, this); mYearPickerView = new YearPickerView(activity, this); // if theme mode has not been set by java code, check if it is specified in Style.xml if (!mThemeDarkChanged) { mThemeDark = Utils.isDarkTheme(activity, mThemeDark); } Resources res = getResources(); mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description); mSelectDay = res.getString(R.string.mdtp_select_day); mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description); mSelectYear = res.getString(R.string.mdtp_select_year); int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme : R.color.mdtp_date_picker_view_animator; view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource)); mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator); mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.setDateMillis(mCalendar.getTimeInMillis()); // TODO: Replace with animation decided upon by the design team. Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); // TODO: Replace with animation decided upon by the design team. Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); mOkButton = (Button) view.findViewById(R.id.ok); mOkButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); notifyOnDateListener(); dismiss(); } }); mOkButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mOkString != null) mOkButton.setText(mOkString); else mOkButton.setText(Utils.getStringFromLocale(getContext(), mOkResid, getLocale())); mCancelButton = (Button) view.findViewById(R.id.cancel); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); mCancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mCancelString != null) mCancelButton.setText(mCancelString); else mCancelButton.setText(Utils.getStringFromLocale(getContext(), mCancelResid, getLocale())); mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); } if (mDayOfWeekView != null) mDayOfWeekView.setBackgroundColor(Utils.darkenColor(mAccentColor)); view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor); mOkButton.setTextColor(mAccentColor); mCancelButton.setTextColor(mAccentColor); if (getDialog() == null) { view.findViewById(R.id.done_background).setVisibility(View.GONE); } updateDisplay(false); setCurrentView(currentView); if (listPosition != -1) { if (currentView == MONTH_AND_DAY_VIEW) { mDayPickerView.postSetSelection(listPosition); } else if (currentView == YEAR_VIEW) { mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset); } } mHapticFeedbackController = new HapticFeedbackController(activity); return view; }
From source file:com.example.innf.newchangtu.Map.view.activity.MainActivity.java
@SuppressWarnings("deprecation") @Override// w w w . jav a2s. com protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /*?*/ mUser = User.getCurrentUser(User.class); bmobQuery = new BmobQuery<>(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); navigationView = (NavigationView) findViewById(R.id.navigation); mToolbar = (Toolbar) findViewById(R.id.action_toolbar); mCollapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar_layout); mPositionRecyclerView = (RecyclerView) findViewById(R.id.position_recycler_view); mCollapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar_layout); mContainMapLayout = (ContainMapLayout) findViewById(R.id.contain_map_layout); mEmptyView = (LinearLayout) findViewById(R.id.empty_view); /*LinearLayoutManagerRecyclerView???*/ LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setReverseLayout(true); /*RecyclerView?*/ layoutManager.setStackFromEnd(true);/*??*/ mPositionRecyclerView.setLayoutManager(layoutManager); if (null != mToolbar) { setSupportActionBar(mToolbar); } if (savedInstanceState != null) { mTrack = (Track) savedInstanceState.getSerializable(KEY_TRACK); mStartPosition = savedInstanceState.getString(KEY_START_POSITION); mEndPosition = savedInstanceState.getString(KEY_END_POSITION); mTimeInterval = savedInstanceState.getInt(KEY_TIME_INTERVAL); mPhone = savedInstanceState.getString(KEY_PHONE); } final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); mDrawerLayout.setDrawerListener(toggle); // toggle.setDrawerIndicatorEnabled(false);//false toggle.syncState(); toggle.setToolbarNavigationClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // openDrawerLayout(); toggle.onDrawerOpened(mDrawerLayout); } }); ActionBar actionBar = getSupportActionBar(); if (null != actionBar) { actionBar.setHomeAsUpIndicator(R.drawable.ic_menu); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); } initFAB(); initNavigationView();/*navigationViewItem?*/ initMap(); updateUI(); mContainMapLayout.setCollapsingToolbarLayout(mCollapsingToolbarLayout); /*Draw Menu ?*/ bmobQuery.getObject(mUser.getObjectId(), new QueryListener<User>() { @Override public void done(User user, BmobException e) { if (e == null) { TextView username = (TextView) findViewById(R.id.user_name_text_view); String name = (String) BmobUser.getObjectByKey("username"); username.setText(name); TextView mobilePhoneNumber = (TextView) findViewById(R.id.user_phone_number_text_view); String phone = (String) BmobUser.getObjectByKey("mobilePhoneNumber"); mobilePhoneNumber.setText(phone); } } }); // ??? requestRuntimePermiussion(new String[] { Manifest.permission.INTERNET, Manifest.permission.SEND_SMS, Manifest.permission.WRITE_SETTINGS, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CHANGE_WIFI_STATE, Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, Manifest.permission.READ_LOGS, Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.WAKE_LOCK, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE }, new PermissionListener() { @Override public void onGranted() { } @Override public void onDenied(List<String> deniedPermission) { for (String permission : deniedPermission) { showToast("???" + permission + ", ???"); } } }); }
From source file:com.fenlisproject.elf.core.framework.ElfBinder.java
public static void bindFragmentArgument(Fragment receiver) { Field[] fields = receiver.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true);/* w ww .j a v a 2s . c o m*/ FragmentArgument fragmentArgument = field.getAnnotation(FragmentArgument.class); if (fragmentArgument != null) { try { Bundle bundle = receiver.getArguments(); if (bundle != null) { Class<?> type = field.getType(); if (type == Boolean.class || type == boolean.class) { field.set(receiver, bundle.getBoolean(fragmentArgument.value())); } else if (type == Byte.class || type == byte.class) { field.set(receiver, bundle.getByte(fragmentArgument.value())); } else if (type == Character.class || type == char.class) { field.set(receiver, bundle.getChar(fragmentArgument.value())); } else if (type == Double.class || type == double.class) { field.set(receiver, bundle.getDouble(fragmentArgument.value())); } else if (type == Float.class || type == float.class) { field.set(receiver, bundle.getFloat(fragmentArgument.value())); } else if (type == Integer.class || type == int.class) { field.set(receiver, bundle.getInt(fragmentArgument.value())); } else if (type == Long.class || type == long.class) { field.set(receiver, bundle.getLong(fragmentArgument.value())); } else if (type == Short.class || type == short.class) { field.set(receiver, bundle.getShort(fragmentArgument.value())); } else if (type == String.class) { field.set(receiver, bundle.getString(fragmentArgument.value())); } else if (type == Boolean[].class || type == boolean[].class) { field.set(receiver, bundle.getBooleanArray(fragmentArgument.value())); } else if (type == Byte[].class || type == byte[].class) { field.set(receiver, bundle.getByteArray(fragmentArgument.value())); } else if (type == Character[].class || type == char[].class) { field.set(receiver, bundle.getCharArray(fragmentArgument.value())); } else if (type == Double[].class || type == double[].class) { field.set(receiver, bundle.getDoubleArray(fragmentArgument.value())); } else if (type == Float[].class || type == float[].class) { field.set(receiver, bundle.getFloatArray(fragmentArgument.value())); } else if (type == Integer[].class || type == int[].class) { field.set(receiver, bundle.getIntArray(fragmentArgument.value())); } else if (type == Long[].class || type == long[].class) { field.set(receiver, bundle.getLongArray(fragmentArgument.value())); } else if (type == Short[].class || type == short[].class) { field.set(receiver, bundle.getShortArray(fragmentArgument.value())); } else if (type == String[].class) { field.set(receiver, bundle.getStringArray(fragmentArgument.value())); } else if (Serializable.class.isAssignableFrom(type)) { field.set(receiver, bundle.getSerializable(fragmentArgument.value())); } else if (type == Bundle.class) { field.set(receiver, bundle.getBundle(fragmentArgument.value())); } } } catch (IllegalAccessException e) { e.printStackTrace(); } } } }
From source file:cs.man.ac.uk.tavernamobile.WorkflowDetail.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.workflow_detail); Activity_Starter_Code = 1;//w ww . j a v a 2s . c om imageCache = TavernaAndroid.getmMemoryCache(); mCache = TavernaAndroid.getmTextCache(); currentActivity = this; // for the access of current activity in // OnClickListener SlidingMenu slidingMenu = new SlidingMenu(this); slidingMenu.setMode(SlidingMenu.LEFT); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); slidingMenu.setShadowWidthRes(R.dimen.shadow_width); slidingMenu.setShadowDrawable(R.drawable.shadow); slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset); slidingMenu.setFadeDegree(0.35f); slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); slidingMenu.setMenu(R.layout.sliding_menu); // UI components ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle("Workflow Details"); actionBar.setIcon(this.getResources().getDrawable(R.drawable.taverna_wheel_logo_medium)); // avatar = (ImageView) findViewById(R.id.avatarImage); title = (TextView) findViewById(R.id.workflowTitle); TextView version = (TextView) findViewById(R.id.workflowVersion); userName = (TextView) findViewById(R.id.uploaderName); final Button launch = (Button) findViewById(R.id.workflowlaunchButton); // try to get data passed and then load other data e.g. license etc. workflow = (Workflow) getIntent().getSerializableExtra("workflow_details"); // If no data passed in - activity restored etc. // get data from memory if the activity was in back stack if (workflow == null) { workflow = (Workflow) mCache.get("workflow"); license = (License) mCache.get("license"); uploader = (User) mCache.get("uploader"); } // if it is not in Cache else if (workflow == null) { // try to get data from savedInstanceState if the activity // was killed due to low memory etc. if (savedInstanceState != null) { // try to get data from saved instance state if (workflow == null) { workflow = (Workflow) savedInstanceState.getSerializable("workflow"); } if (license == null) { license = (License) savedInstanceState.getSerializable("license"); } if (uploader == null) { uploader = (User) savedInstanceState.getSerializable("uploader"); } } } else if (workflow == null) { // if data can't even be loaded from // saved instance state, inform user // to try start the activity again, // rather than crash the application MessageHelper.showMessageDialog(currentActivity, "Oops !", "No workflow data found," + "please try again.\n(The message will be dismissed in 4 seconds)", null); new Handler().postDelayed(new Runnable() { public void run() { currentActivity.finish(); } }, 4000); return; } /** "workflow" should never be null at this point **/ title.setText(workflow.getTitle()); version.setText("Version " + workflow.getVersion()); // any of the following is null we retrieve data from the server if (license == null || uploader == null || avatarBitmap == null) { BackgroundTaskHandler handler = new BackgroundTaskHandler(); handler.StartBackgroundTask(this, this, "Loading workflow data..."); } else { // load avatar image from cache avatarBitmap = imageCache.get(uploader.getAvatar().getResource()); } launch.setOnClickListener(new android.view.View.OnClickListener() { public void onClick(View v) { SystemStatesChecker sysChecker = new SystemStatesChecker(currentActivity); if (!(sysChecker.isNetworkConnected())) { return; } WorkflowBE workflowEntity = new WorkflowBE(); workflowEntity.setTitle(workflow.getTitle()); workflowEntity.setVersion(workflow.getVersion()); workflowEntity.setWorkflow_URI(workflow.getContent_uri()); workflowEntity.setUploaderName(workflow.getUploader().getValue()); workflowEntity.setAvatar(Bitmap.createScaledBitmap(avatarBitmap, 100, 100, true)); List<String> privilegesStrings = new ArrayList<String>(); List<Privilege> privileges = workflow.getPrivileges(); for (Privilege privilege : privileges) { privilegesStrings.add(privilege.getType()); } workflowEntity.setPrivileges(privilegesStrings); WorkflowLaunchHelper launchHelper = new WorkflowLaunchHelper(currentActivity, Activity_Starter_Code); launchHelper.launch(workflowEntity, 0); } }); // Set up fragments DetailsPreviewFragment previewFragment = new DetailsPreviewFragment(); DetailsDescriptionFragment descriptionFragment = new DetailsDescriptionFragment(); DetailsLicenseFragment licenseFragment = new DetailsLicenseFragment(); mSectionsPagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); mSectionsPagerAdapter.addFragment(previewFragment); mSectionsPagerAdapter.addFragment(descriptionFragment); mSectionsPagerAdapter.addFragment(licenseFragment); mViewPager = (ViewPager) findViewById(R.id.workflowDetailsViewPager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(2); mViewPager.setCurrentItem(0); /*myExperimentLoginText = (TextView) findViewById(R.id.wfdMyExperimentLoginState); myExperimentLoginText.setOnClickListener(new android.view.View.OnClickListener() { @Override public void onClick(View v) { User user = TavernaAndroid.getMyEUserLoggedin(); if (user != null) { MessageHelper.showOptionsDialog(currentActivity, "Do you wish to log out ?", "Attention", new CallbackTask() { @Override public Object onTaskInProgress(Object... param) { // Clear user logged-in and cookie TavernaAndroid.setMyEUserLoggedin(null); TavernaAndroid.setMyExperimentSessionCookies(null); refreshLoginState(); return null; } @Override public Object onTaskComplete(Object... result) {return null;} }, null); }else{ Intent gotoMyexperimentLogin = new Intent( currentActivity, MyExperimentLogin.class); currentActivity.startActivity(gotoMyexperimentLogin); } } });*/ this.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out); }