List of usage examples for android.widget ListView setDivider
public void setDivider(@Nullable Drawable divider)
From source file:com.igniva.filemanager.fragments.AppsList.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setRetainInstance(true);/*ww w. j a v a2 s. c o m*/ mainActivity = (MainActivity) getActivity(); mainActivity.setActionBarTitle(utils.getString(getActivity(), R.string.apps)); mainActivity.floatingActionButton.hideMenuButton(true); mainActivity.buttonBarFrame.setVisibility(View.GONE); mainActivity.supportInvalidateOptionsMenu(); vl = getListView(); Sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); getSortModes(); ListView vl = getListView(); int theme = Integer.parseInt(Sp.getString("theme", "0")); theme1 = theme == 2 ? PreferenceUtils.hourOfDay() : theme; vl.setDivider(null); if (theme1 == 1) getActivity().getWindow().getDecorView() .setBackgroundColor(getResources().getColor(R.color.holo_dark_background)); if (savedInstanceState == null) loadlist(false); else { c = savedInstanceState.getParcelableArrayList("c"); a = savedInstanceState.getParcelableArrayList("list"); adapter = new AppsAdapter(getActivity(), R.layout.rowlayout, a, app, c); setListAdapter(adapter); vl.setSelectionFromTop(savedInstanceState.getInt("index"), savedInstanceState.getInt("top")); vl.setSelectionFromTop(savedInstanceState.getInt("index"), savedInstanceState.getInt("top")); } setHasOptionsMenu(true); }
From source file:qr.cloud.qrpedia.SavedTextListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // configure the list view ListView listView = getListView(); QRCloudUtils.setListViewEmptyView(listView, getString(R.string.no_saved_messages), R.string.default_font, R.dimen.activity_horizontal_margin, R.dimen.activity_vertical_margin); listView.setSelector(R.drawable.message_row_selector); // override the default selector listView.setDivider(new ColorDrawable(this.getResources().getColor(R.color.list_divider))); listView.setDividerHeight(1);//from ww w .j a v a 2 s . c o m listView.setOnItemLongClickListener(mLongClickListener); if (mIsInDialog && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // fix black background issue pre-honeycomb listView.setBackgroundColor(Color.WHITE); } }
From source file:eu.trentorise.smartcampus.jp.MyRecurItinerariesFragment.java
@Override public void onStart() { super.onStart(); ListView myJourneysList = (ListView) getView().findViewById(R.id.myitineraries_list); myItineraries = new ArrayList<BasicRecurrentJourney>(); adapter = new MyRecurItinerariesListAdapter(getSherlockActivity(), R.layout.recur_itinerarychoices_row, myItineraries);/*from w ww .j a v a 2s . c om*/ myJourneysList.setAdapter(adapter); myJourneysList.setDivider(null); myJourneysList.setDividerHeight(Utils.convertDpToPixel(6, getActivity())); SCAsyncTask<Void, Void, List<BasicRecurrentJourney>> task = new SCAsyncTask<Void, Void, List<BasicRecurrentJourney>>( getSherlockActivity(), new GetMyRecurItinerariesProcessor(getSherlockActivity(), adapter)); task.execute(); myJourneysList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager() .beginTransaction(); Fragment fragment = new MyRecurItineraryFragment(); Bundle b = new Bundle(); b.putSerializable(MyRecurItineraryFragment.PARAMS, adapter.getItem(position)); b.putBoolean(MyRecurItineraryFragment.PARAM_EDITING, false); fragment.setArguments(b); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); fragmentTransaction.replace(Config.mainlayout, fragment, Config.MY_RECUR_JOURNEYS_FRAGMENT_TAG); fragmentTransaction.addToBackStack(fragment.getTag()); fragmentTransaction.commit(); } }); }
From source file:com.nttec.everychan.ui.theme.CustomThemeHelper.java
@Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { int mappingCount = 0; if (attrs != null) { for (int i = 0, size = attrs.getAttributeCount(); i < size; ++i) { String value = attrs.getAttributeValue(i); if (!value.startsWith("?")) continue; int attrId = resources.getIdentifier(value.substring(1), null, null); //Integer.parseInt(value.substring(1)); if (attrId == 0) { Logger.e(TAG, "couldn't get id for attribute: " + value); continue; }/*from w w w .j ava2s . co m*/ int index = customAttrs.indexOfKey(attrId); if (index >= 0) { mappingKeys[mappingCount] = attrs.getAttributeNameResource(i); mappingValues[mappingCount] = customAttrs.valueAt(index); ++mappingCount; } } } if (mappingCount == 0 && textColorPrimaryOverridden == textColorPrimaryOriginal) return null; View view = instantiate(name, context, attrs); if (view == null) return null; boolean shouldOverrideTextColor = textColorPrimaryOverridden != textColorPrimaryOriginal && view instanceof TextView; for (int i = 0; i < mappingCount; ++i) { switch (mappingKeys[i]) { case android.R.attr.background: view.setBackgroundColor(mappingValues[i]); break; case android.R.attr.textColor: if (view instanceof TextView) { ((TextView) view).setTextColor(mappingValues[i]); shouldOverrideTextColor = false; } else { Logger.e(TAG, "couldn't apply attribute 'textColor' on class " + name + " (not instance of TextView)"); } break; case android.R.attr.divider: if (view instanceof ListView) { ListView listView = (ListView) view; int dividerHeight = listView.getDividerHeight(); listView.setDivider(new ColorDrawable(mappingValues[i])); listView.setDividerHeight(dividerHeight); } else { Logger.e(TAG, "couldn't apply attribute 'divider' on class " + name + " (not instance of ListView)"); } break; default: String attrResName = null; try { attrResName = resources.getResourceName(mappingKeys[i]); } catch (Exception e) { attrResName = Integer.toString(mappingKeys[i]); } Logger.e(TAG, "couldn't apply attribure '" + attrResName + "' on class " + name); } } if (shouldOverrideTextColor) { TextView tv = (TextView) view; if (tv.getCurrentTextColor() == textColorPrimaryOriginal) { tv.setTextColor(textColorPrimaryOverridden); } } return view; }
From source file:com.mrpoid.mrplist.ui.MrpListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); initPathStack();/*from ww w . jav a 2s . c o m*/ setHasOptionsMenu(true); setListShown(false); mAdapter = new MrpListAdapter(getActivity()); setListAdapter(mAdapter); ListView listView = getListView(); registerForContextMenu(listView); listView.setOnItemLongClickListener(this); listView.setFastScrollEnabled(true); listView.setCacheColorHint(Color.TRANSPARENT); if (PreferencesProvider.Interface.General.getThemeImage(0) >= 2) { listView.setDivider(new ColorDrawable(Color.TRANSPARENT)); listView.setDividerHeight(1); } getLoaderManager().initLoader(1001, null, this); }
From source file:org.telegram.ui.PrivacySettingsActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("PrivacySettings", R.string.PrivacySettings)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/*w w w. j av a 2 s . c o m*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ListView listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == blockedRow) { presentFragment(new BlockedUsersActivity()); } else if (i == sessionsRow) { presentFragment(new SessionsActivity()); } else if (i == deleteAccountRow) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("DeleteAccountTitle", R.string.DeleteAccountTitle)); builder.setItems( new CharSequence[] { LocaleController.formatPluralString("Months", 1), LocaleController.formatPluralString("Months", 3), LocaleController.formatPluralString("Months", 6), LocaleController.formatPluralString("Years", 1) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int value = 0; if (which == 0) { value = 30; } else if (which == 1) { value = 90; } else if (which == 2) { value = 182; } else if (which == 3) { value = 365; } final ProgressDialog progressDialog = new ProgressDialog(getParentActivity()); progressDialog .setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.show(); final TLRPC.TL_account_setAccountTTL req = new TLRPC.TL_account_setAccountTTL(); req.ttl = new TLRPC.TL_accountDaysTTL(); req.ttl.days = value; ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { progressDialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } if (response instanceof TLRPC.TL_boolTrue) { ContactsController.getInstance() .setDeleteAccountTTL(req.ttl.days); listAdapter.notifyDataSetChanged(); } } }); } }); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } else if (i == lastSeenRow) { presentFragment(new PrivacyControlActivity(false)); } else if (i == groupsRow) { presentFragment(new PrivacyControlActivity(true)); } else if (i == passwordRow) { presentFragment(new TwoStepVerificationActivity(0)); } else if (i == passcodeRow) { if (UserConfig.passcodeHash.length() > 0) { presentFragment(new PasscodeActivity(2)); } else { presentFragment(new PasscodeActivity(0)); } } else if (i == secretWebpageRow) { if (MessagesController.getInstance().secretWebpagePreview == 1) { MessagesController.getInstance().secretWebpagePreview = 0; } else { MessagesController.getInstance().secretWebpagePreview = 1; } ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE) .edit().putInt("secretWebpage2", MessagesController.getInstance().secretWebpagePreview) .commit(); if (view instanceof TextCheckCell) { ((TextCheckCell) view) .setChecked(MessagesController.getInstance().secretWebpagePreview == 1); } } } }); return fragmentView; }
From source file:com.tomer.alwayson.SettingsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); rootView = getView();// w ww .j a v a 2 s . co m assert rootView != null; ListView list = (ListView) rootView.findViewById(android.R.id.list); list.setDivider(null); prefs = new Prefs(context); prefs.apply(); if (hasSoftKeys()) { findPreference(BACK_BUTTON).setEnabled(false); } else { if (!prefs.neverShowPluginDialog) { if (!isPackageInstalled("tomer.com.alwaysonamoledplugin")) { //Prompt to install the plugin AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder.setTitle(getString(R.string.plugin_dialog_title)) .setMessage(getString(R.string.plugin_dialog_desc)) .setPositiveButton("Download", (dialogInterface, i) -> { openPlayStoreUrl("tomer.com.alwaysonamoledplugin", context); dialogInterface.dismiss(); }).setCancelable(false); if (prefs.showedPluginDialog) alertDialogBuilder.setNeutralButton(getString(R.string.never_show_again), (dialogInterface, i) -> prefs.setBool(Prefs.KEYS.NEVER_SHOW_DIALOG.toString(), true)); alertDialogBuilder.show(); prefs.setBool(Prefs.KEYS.SHOWED_DIALOG.toString(), true); } } } version(context); translate(); googlePlusCommunitySetup(); openSourceLicenses(); githubLink(); }
From source file:org.telegram.ui.myLocationSettingsActivity.java
@Override public View createView(LayoutInflater inflater) { if (fragmentView == null) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle("My Places"); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override//from w ww.j a v a 2s. co m public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(getParentActivity()); fragmentView = new FrameLayout(getParentActivity()); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(0xfff0f0f0); ListView listView = new ListView(getParentActivity()); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == homeRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle("Home"); final ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(50, 30); final EditText input = new EditText(getParentActivity()); input.setHint("Insert city"); input.setLayoutParams(lparams); builder.setView(input); builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().trim().length() > 0) { String city = input.getText().toString().trim(); try { Bundle locationHome = new getCoordinates().execute(city).get(); String latHome = locationHome.getString("lat"); String lonHome = locationHome.getString("lon"); SharedPreferences sharedPreferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("latHome", latHome); editor.putString("longHome", lonHome); editor.commit(); Log.i(TAG, "fine! " + lonHome); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show(); } }); showAlertDialog(builder); } else if (i == workRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle("Work"); final EditText input = new EditText(getParentActivity()); input.setHint("Insert city"); builder.setView(input); builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().trim().length() > 0) { String city = input.getText().toString().trim(); try { Bundle locationWork = new getCoordinates().execute(city).get(); String latWork = locationWork.getString("lat"); String lonWork = locationWork.getString("lon"); SharedPreferences sharedPreferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("latWork", latWork); editor.putString("longWork", lonWork); editor.commit(); Log.i(TAG, "fine! " + latWork); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show(); } }); showAlertDialog(builder); } else if (i == entertainmentRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle("Entertainment"); final EditText input = new EditText(getParentActivity()); input.setHint("Insert city"); builder.setView(input); builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().trim().length() > 0) { String city = input.getText().toString().trim(); try { Bundle locationEntertainment = new getCoordinates().execute(city).get(); String latEntertainment = locationEntertainment.getString("lat"); String lonEntertainment = locationEntertainment.getString("lon"); SharedPreferences sharedPreferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("latEntertainment", latEntertainment); editor.putString("longEntertainment", lonEntertainment); editor.commit(); Log.i(TAG, "fine! " + latEntertainment); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else { Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show(); } }); showAlertDialog(builder); } //TODO find a solution for commuteRow as well!! } }); } else { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } } return fragmentView; }
From source file:org.telegram.ui.SessionsActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("SessionsTitle", R.string.SessionsTitle)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/* ww w . j ava 2s.c o m*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); emptyLayout = new LinearLayout(context); emptyLayout.setOrientation(LinearLayout.VERTICAL); emptyLayout.setGravity(Gravity.CENTER); //emptyLayout.setBackgroundResource(R.drawable.greydivider_bottom); emptyLayout.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight())); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.devices); emptyLayout.addView(imageView); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams(); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; imageView.setLayoutParams(layoutParams2); TextView textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.disabled_text) /*0xff8a8a8a*/); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setText(LocaleController.getString("NoOtherSessions", R.string.NoOtherSessions)); emptyLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.topMargin = AndroidUtilities.dp(16); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER; textView.setLayoutParams(layoutParams2); textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.disabled_text) /*0xff8a8a8a*/); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); textView.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0); textView.setText(LocaleController.getString("NoOtherSessionsInfo", R.string.NoOtherSessionsInfo)); emptyLayout.addView(textView); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams(); layoutParams2.topMargin = AndroidUtilities.dp(14); layoutParams2.width = LayoutHelper.WRAP_CONTENT; layoutParams2.height = LayoutHelper.WRAP_CONTENT; layoutParams2.gravity = Gravity.CENTER; textView.setLayoutParams(layoutParams2); FrameLayout progressView = new FrameLayout(context); frameLayout.addView(progressView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; progressView.setLayoutParams(layoutParams); progressView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); ProgressBar progressBar = new ProgressBar(context); progressView.addView(progressBar); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER; progressView.setLayoutParams(layoutParams); ListView listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); listView.setEmptyView(progressView); frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == terminateAllSessionsRow) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage( LocaleController.getString("AreYouSureSessions", R.string.AreYouSureSessions)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { TLRPC.TL_auth_resetAuthorizations req = new TLRPC.TL_auth_resetAuthorizations(); ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (getParentActivity() == null) { return; } if (error == null && response instanceof TLRPC.TL_boolTrue) { Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), Toast.LENGTH_SHORT); toast.show(); } else { Toast toast = Toast .makeText(getParentActivity(), LocaleController.getString("UnknownError", R.string.UnknownError), Toast.LENGTH_SHORT); toast.show(); } finishFragment(); } }); UserConfig.registeredForPush = false; UserConfig.saveConfig(false); MessagesController.getInstance().registerForPush(UserConfig.pushString); ConnectionsManager.getInstance() .setUserId(UserConfig.getClientUserId()); } }); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } else if (i >= otherSessionsStartRow && i < otherSessionsEndRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("TerminateSessionQuestion", R.string.TerminateSessionQuestion)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int option) { final ProgressDialog progressDialog = new ProgressDialog(getParentActivity()); progressDialog .setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.show(); final TLRPC.TL_authorization authorization = sessions .get(i - otherSessionsStartRow); TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization(); req.hash = authorization.hash; ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { progressDialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } if (error == null) { sessions.remove(authorization); updateRows(); if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } } } }); } }); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } } }); return fragmentView; }
From source file:org.telegram.ui.PrivacyControlActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); if (isGroup) { actionBar.setTitle(LocaleController.getString("GroupsAndChannels", R.string.GroupsAndChannels)); } else {//from ww w .j a v a 2 s .c o m actionBar.setTitle(LocaleController.getString("PrivacyLastSeen", R.string.PrivacyLastSeen)); } actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (getParentActivity() == null) { return; } if (currentType != 0 && !isGroup) { final SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); boolean showed = preferences.getBoolean("privacyAlertShowed", false); if (!showed) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); if (isGroup) { builder.setMessage( LocaleController.getString("WhoCanAddMeInfo", R.string.WhoCanAddMeInfo)); } else { builder.setMessage(LocaleController.getString("CustomHelp", R.string.CustomHelp)); } builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { applyCurrentPrivacySettings(); preferences.edit().putBoolean("privacyAlertShowed", true).commit(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); return; } } applyCurrentPrivacySettings(); } } }); ActionBarMenu menu = actionBar.createMenu(); doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); doneButton.setVisibility(View.GONE); listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ListView listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == nobodyRow || i == everybodyRow || i == myContactsRow) { int newType = currentType; if (i == nobodyRow) { newType = 1; } else if (i == everybodyRow) { newType = 0; } else if (i == myContactsRow) { newType = 2; } if (newType == currentType) { return; } enableAnimation = true; doneButton.setVisibility(View.VISIBLE); lastCheckedType = currentType; currentType = newType; updateRows(); } else if (i == neverShareRow || i == alwaysShareRow) { ArrayList<Integer> createFromArray; if (i == neverShareRow) { createFromArray = currentMinus; } else { createFromArray = currentPlus; } if (createFromArray.isEmpty()) { Bundle args = new Bundle(); args.putBoolean(i == neverShareRow ? "isNeverShare" : "isAlwaysShare", true); args.putBoolean("isGroup", isGroup); GroupCreateActivity fragment = new GroupCreateActivity(args); fragment.setDelegate(new GroupCreateActivity.GroupCreateActivityDelegate() { @Override public void didSelectUsers(ArrayList<Integer> ids) { if (i == neverShareRow) { currentMinus = ids; for (int a = 0; a < currentMinus.size(); a++) { currentPlus.remove(currentMinus.get(a)); } } else { currentPlus = ids; for (int a = 0; a < currentPlus.size(); a++) { currentMinus.remove(currentPlus.get(a)); } } doneButton.setVisibility(View.VISIBLE); lastCheckedType = -1; listAdapter.notifyDataSetChanged(); } }); presentFragment(fragment); } else { PrivacyUsersActivity fragment = new PrivacyUsersActivity(createFromArray, isGroup, i == alwaysShareRow); fragment.setDelegate(new PrivacyUsersActivity.PrivacyActivityDelegate() { @Override public void didUpdatedUserList(ArrayList<Integer> ids, boolean added) { if (i == neverShareRow) { currentMinus = ids; if (added) { for (int a = 0; a < currentMinus.size(); a++) { currentPlus.remove(currentMinus.get(a)); } } } else { currentPlus = ids; if (added) { for (int a = 0; a < currentPlus.size(); a++) { currentMinus.remove(currentPlus.get(a)); } } } doneButton.setVisibility(View.VISIBLE); listAdapter.notifyDataSetChanged(); } }); presentFragment(fragment); } } } }); return fragmentView; }