Splitting a string Value into chunks of a certain size - substring

public static void SplittingStringIntoChunksCounts(string InputValue)
{
int ChunkSize = 5;
InputValue = "TestingManualTestingAutomTesting";
Dictionary<string, int> dictValue = new Dictionary<string, int>();
for (int i = 0; i < InputValue.Length; i += chunkSize)
{
if (i + chunkSize <= InputValue.Length)
{
Console.WriteLine(InputValue.Substring(i, chunkSize));
string tempValue = InputValue.Substring(i, chunkSize);
if (dictValue.ContainsKey(tempValue))
//if (!dictValue.ContainsKey(tempValue))
{
dictValue[tempValue]++;
//dictValue[tempValue] = 0;
}
else { dictValue[tempValue] = 1; }
// dictValue[tempValue]++;
}
}
foreach (var item in dictValue)
{
Console.WriteLine("Input User== " + " " + item.Key + " " + "Number of Time" + " " + item.Value);
}
}
foreach (var item in dictValue)
{
Console.WriteLine("Input User== " + " " + item.Key + " " + "Number of Time" + " " + item.Value);
}

Related

LootLocker - How to show local rank

In my game, I am able to show the GlobalRank, however, I would also like to show the position of a player in Ranking according to the global results.
So in the bottom line, there should be the local (on this device) results.
Basically, on the left bottom corner, I want to get the RANK from the LootLocker, but I am struggling to get the rank...
IEnumerator ShowScores()
{
yield return new WaitForSeconds(2);
LootLockerSDKManager.GetScoreList(ID, maxScores, (response) =>
{
if (response.success)
{
LootLockerLeaderboardMember[] scores = response.items;
for (int i = 0; i < scores.Length; i++)
{
playerNames[i].text = (scores[i].member_id +"");
playerScores[i].text = (scores[i].score +"");
playerRank[i].text = (scores[i].rank + "");
//Rank of the localPlayer
Rank.text = (scores["here_Should_Be_This_Player_ID"].rank + "");
LootLockerSDKManager.GetPlayerName
// Entries[i].text = (scores[i].rank + ". " + scores[i].score + ". " + scores[i].member_id);
}
if (scores.Length < maxScores)
{
for (int i = scores.Length; i < maxScores; i++)
{
// Entries[i].text = (i + 1).ToString() + ". none";
}
}
}
else
{
}
});
}
Fixed it with the LootLocker support team
Step 1 - load LootLocker and get the resonse
Step 2 - load the rank and get the resonse2
Step 3 - use the "Response2.rank from the LootLocker
Rank.text = (response2.rank + "");
string playerIdentifier = "PlayerNameRecordOnThisDevice";
LootLockerSDKManager.StartSession(playerIdentifier, (response) =>
{
if (response.success)
{
Debug.Log("session with LootLocker started");
}
else
{
Debug.Log("failed to start sessions" + response.Error);
}
LootLockerSDKManager.GetMemberRank(ID, playerIdentifier, (response2) =>
{
if (response2.statusCode == 200)
{
Debug.Log("GetMemberRank Successful");
}
else
{
Debug.Log("GetMemberRank failed: " + response2.Error);
}
Rank.text = (response2.rank + "");
});
}); ```

Firebase fetch inside for loop not working properly

In my project, I took data from the android accessibility stream in a headless background function turned them into an array and split them into chunks for firebase limits, and used a for loop to iterate over them and check in firebase. Sometimes this is not working, especially since I can see the associability service runner but showing data from a bit ago. I think this happens when the user is offline and tried to fetch data from firebase. Can you please have a look at this code and tell me what the issue is and How I should solve it?
N.B: I changed some variable names for privacy purposes. There are no issues with them.
FlutterAccessibilityService.accessStream.listen((event) {
if (event.capturedText != null &&
event.capturedText != "" &&
isCold) {
text = event.capturedText!.toLowerCase();
List textList = getArray(text);
final sharedItems = getSimilarArray(fbtag, textList, sensitivity);
final sharedLocalItems =
getSimilarLocalArray(fbtag, textList, sensitivity);
final sharedAbsItems = getAbsLocalArray(fbtag, textList);
final sharedItemWithLastEval =
getSimilarArray(lastEvaluatedText, textList, sensitivity);
if (text != lastEventText &&
(sharedItemWithLastEval.length == 0 ||
lastEvaluatedText[0] == "first")) {
print("called related content");
print("bg currant text: " +
text.toString() +
" sensitivity: " +
sensitivity.toString() +
" minimumAbsMatch: " +
minimumAbsMatch.toString() +
" shared local items: " +
sharedLocalItems.toString() +
" shared abs items: " +
sharedAbsItems.toString() +
" shared items: " +
sharedItems.toString() +
" last : " +
lastEventText +
" last eval text: " +
lastEvaluatedText.toString() +
" Cold: " +
isCold.toString());
print("captured text: " + text.toString());
//GetRelatedContent(fbtag, event.capturedText);
print(sharedItems);
if (sharedLocalItems.length >= accuracy &&
sharedAbsItems.length >= minimumAbsMatch) {
print("main called");
List result = [];
lastEvaluatedText = sharedItems;
List chunkedList = chunking(sharedItems);
for (int i = 0; i < chunkedList.length; i++) {
FirebaseFirestore.instance
.collection('Content')
.where('keyWords', arrayContainsAny: chunkedList[i])
.get()
.then((value) {
for (int i = 0; i < value.docs.length; i++) {
result.add(value.docs[i].data());
print("sep");
print("result: " + result.toString());
}
if (i == chunkedList.length - 1) {
if (result.isNotEmpty) {
print("final result: " +
result[HighestMatchingIndex(sharedItems, result)[0]]
.toString());
print('result length called' +
' result: ' +
result.toString());
if (HighestMatchingIndex(sharedItems, result)[1] >=
accuracy) {
print('overlay called');
isCold = false;
Timer(Duration(seconds: 60), () {
print("Cold down");
isCold = true;
});
var FinalResult = result[
HighestMatchingIndex(sharedItems, result)[0]];
if (FinalResult['availableCountry']
.contains(country) &&
FinalResult['availableR']
.contains(r)) {
print("all passed");
String l = FinalResult[r]
[country] ??
FinalResult[r]['EN'];
String o =
FinalResult[r]['origin'];
ShowAlert(l, o, r);
}
}
}
}
});
}
}
//
}
lastEventText = text;
}
});

How to solve a TabLayout inside a Fragment which includes four Tabs created by one Fragment with newInstance() using RecyclerView

I implement an Activity which contains a NavigationView with includes several fragments. The first Fragment of the NavigationView contains a RecyclerView with a TabLayout, so that I can swipe between the different lists. Because I've got always the same list(UI) with different values, I decided to implement only one Fragment with a newInstance().
My problem now is that the list does not update properly when I jump from Tab1 to Tab2 or if I change a list item and come back to the list. Can somebody help me? I can't figure it out ...
swipe from Tab1 to Tab2
This is my fragment which contains the RecyclerView:
public class HinweiseFragment extends Fragment {
private static final String TAG = "HinweiseFragment";
private TabLayout mTabLayout;
private ViewPager mViewPager;
private HinweiseTabAdapter adapter;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
((MainActivity) getActivity()).getSupportActionBar().setTitle("Hinweise");
((MainActivity) getActivity()).showFloatingActionButton();
View rootView = inflater.inflate(R.layout.fragment_hinweise, null);
mTabLayout = (TabLayout) rootView.findViewById(R.id.tablayout_hinweise);
mTabLayout.addTab(mTabLayout.newTab().setText("BESAMUNG"));
mTabLayout.addTab(mTabLayout.newTab().setText("NICHT BESAMEN"));
mTabLayout.addTab(mTabLayout.newTab().setText("VERDACHT"));
mTabLayout.addTab(mTabLayout.newTab().setText("ALLE"));
mTabLayout.setTabGravity(mTabLayout.GRAVITY_FILL);
mViewPager = (ViewPager) rootView.findViewById(R.id.viewpager_hinweise);
adapter = new HinweiseTabAdapter(getChildFragmentManager(), mTabLayout.getTabCount(), getContext());
mViewPager.setAdapter(adapter);
mViewPager.setOffscreenPageLimit(3);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
#Override
public void onTabSelected(TabLayout.Tab tab) {
mViewPager.setCurrentItem(tab.getPosition(), true);
adapter.refreshFragment(tab.getPosition());
}
#Override
public void onTabUnselected(TabLayout.Tab tab) {
}
#Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
return rootView;
}
}
This is my TabAdapter:
public class HinweiseTabAdapter extends FragmentPagerAdapter {
HinweiseListFragment tab_besamung, tab_nicht, tab_verdacht, tab_alle;
String[] tabHostTitle = {"BESAMUNG", "NICHT BESAMEN", "VERDACHT", "ALLE"};
int mNumOfTabs;
private final Context mContext;
public HinweiseTabAdapter(FragmentManager fm, int NumOfTabs, Context context) {
super(fm);
this.mNumOfTabs = NumOfTabs;
this.mContext = context;
}
#Override
public Fragment getItem(int position) {
switch (position) {
case 0:
tab_besamung = HinweiseListFragment.newInstance(0, "BESAMUNG");
return tab_besamung;
case 1:
tab_nicht = HinweiseListFragment.newInstance(1, "NICHT BESAMEN");
return tab_nicht;
case 2:
tab_verdacht = HinweiseListFragment.newInstance(2, "VERDACHT");
return tab_verdacht;
case 3:
tab_alle = HinweiseListFragment.newInstance(3, "ALLE");
return tab_alle;
default:
return null;
}
}
public void refreshFragment(int position) {
switch (position) {
case 0:
tab_besamung.update();
break;
case 1:
tab_nicht.update();
break;
case 2:
tab_verdacht.update();
break;
case 3:
tab_alle.update();
break;
}
}
#Override
public int getItemPosition(Object object) {
int position = getItemPosition(object);
if (position >= 0) {
return position;
} else {
return POSITION_NONE;
}
}
#Override
public int getCount() {
return mNumOfTabs;
}
#Override
public CharSequence getPageTitle(int position) {
return tabHostTitle[position];
}
}
and this is my Fragment which contains the List:
public static HinweiseListFragment newInstance(int page, String title) {
HinweiseListFragment fragment = new HinweiseListFragment();
Bundle args = new Bundle();
args.putInt(PASSED_PAGE, page);
args.putString(PASSED_TITLE, title);
fragment.setArguments(args);
return fragment;
}
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args != null) {
tabCount = args.getInt(PASSED_PAGE);
tabName = args.getString(PASSED_TITLE);
}
}
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_hinweise_list, container, false);
list_hinweise = new ArrayList<>();
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.rv_listHinweise);
mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeHinweise);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
#Override
public void onRefresh() {
mSwipeRefreshLayout.post(new Runnable() {
#Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
refreshContent();
}
});
}
});
db = new DataBase(getActivity());
userHitKdr();
List<String> tab_ = db.getAll("SELECT * from tab_info where user_tab ='" + userdb + "' ");
if (tab_.size() != 2) {
db.updateSql("delete from tab_info where user_tab='" + userdb + "' ");
db.updateSql("insert into tab_info (activity_tab,tab_select,user_tab) values ('home','0','" + userdb + "'),('aufgabe','0','" + userdb + "'); ");
} else {
}
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mHinweiseAdapter = new HinweiseAdapter(getActivity(), getHinweise());
mRecyclerView.setAdapter(mHinweiseAdapter);
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
#Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
Intent detailView = new Intent(getActivity(), HinweiseDetail.class);
String[] tierarr = new String[tier_id.size()];
tier_id.toArray(tierarr);
String[] hinarr = new String[hin_id.size()];
hin_id.toArray(hinarr);
detailView.putExtra("detailart", "ovalert");
detailView.putExtra("idTier", tier_id.get(position));
detailView.putExtra("idDetail", hin_id.get(position));
int ipos = position;
Integer integerConverter = new Integer(ipos);
String s = integerConverter.toString();
detailView.putExtra("pos", s);
detailView.putExtra("arrIdTier", tierarr);
detailView.putExtra("arrIdHin", hinarr);
detailView.putExtra("userDetail", userdb);
detailView.putExtra("hitDetail", hitdb);
startActivity(detailView);
}
});
return rootView;
}
#Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
if(list_hinweise != null) {
update();
}
}
}
public String checkTab(int tab) {
tabCount = tab;
//tabName = name;
if (tabCount == 0) {
auswahl = " animalReproductionIndication.off='0' and (animalReproductionIndication.indicationCertainty ='IN' or animalReproductionIndication.indicationCertainty ='ID' or animalReproductionIndication.indicationCertainty ='' ) and ";
db.updateSql("update tab_info set tab_select='" + tabCount + "' where activity_tab='home' and user_tab='" + userdb + "' ");
if (list_hinweise != null) {
list_hinweise.clear();
if (mHinweiseAdapter != null) {
mHinweiseAdapter.notifyDataSetChanged();
}
}
}
if (tabCount == 1) {
auswahl = " animalReproductionIndication.off='0' and (animalReproductionIndication.indicationCertainty ='NI' or animalReproductionIndication.indicationCertainty ='HO') and ";
db.updateSql("update tab_info set tab_select='" + tabCount + "' where activity_tab='home' and user_tab='" + userdb + "' ");
if (list_hinweise != null) {
list_hinweise.clear();
if (mHinweiseAdapter != null) {
mHinweiseAdapter.notifyDataSetChanged();
}
}
}
if (tabCount == 2) {
auswahl = " animalReproductionIndication.off='0' and animalReproductionIndication.indicationCertainty ='SU' and ";
db.updateSql("update tab_info set tab_select='" + tabCount + "' where activity_tab='home' and user_tab='" + userdb + "' ");
if (list_hinweise != null) {
list_hinweise.clear();
if (mHinweiseAdapter != null) {
mHinweiseAdapter.notifyDataSetChanged();
}
}
}
if (tabCount == 3) {
auswahl = " animalReproductionIndication.off='0' and (animalReproductionIndication.indicationCertainty ='IN' or animalReproductionIndication.indicationCertainty ='NI' or animalReproductionIndication.indicationCertainty ='SU' or animalReproductionIndication.indicationCertainty ='ID' or animalReproductionIndication.indicationCertainty ='HO') and ";
db.updateSql("update tab_info set tab_select='" + tabCount + "' where activity_tab='home' and user_tab='" + userdb + "' ");
if (list_hinweise != null) {
list_hinweise.clear();
if (mHinweiseAdapter != null) {
mHinweiseAdapter.notifyDataSetChanged();
}
}
}
return auswahl;
}
public void update(){
tabCount = getArguments() != null ? getArguments().getInt(PASSED_PAGE) : 0;
tabName = getArguments() != null ? getArguments().getString(PASSED_TITLE) : "BESAMUNG";
list_hinweise.clear();
mHinweiseAdapter = new HinweiseAdapter(getActivity(), getHinweise());
mRecyclerView.setAdapter(mHinweiseAdapter);
}
public void refreshContent() {
importIndication();
tabCount = getArguments() != null ? getArguments().getInt(PASSED_PAGE) : 0;
tabName = getArguments() != null ? getArguments().getString(PASSED_TITLE) : "BESAMUNG";
list_hinweise.clear();
mHinweiseAdapter = new HinweiseAdapter(getActivity(), getHinweise());
mRecyclerView.setAdapter(mHinweiseAdapter);
// stopping swipe refresh
mSwipeRefreshLayout.setRefreshing(false);
}
private List<ListHinweise> getHinweise() {
checkTab(tabCount);
tm = new DateTime();
rg = new DateRegex();
tt = new DateTime();
try {
db.checkAndCopyDatabase();
db.openDatabase();
} catch (SQLiteException e) {
e.printStackTrace();
}
String sqlSortName = "select nameCode from sortieren where art='1' and (disable='0' or disable='1') and user='" + userdb + "' group by nameCode ";
String sqlSortDisable = "select disable from sortieren where art='1' and (disable='0' or disable='1') and user='" + userdb + "' group by nameCode ";
List<String> listSortName = db.getAll(sqlSortName);
List<String> listSortDisable = db.getAll(sqlSortDisable);
String sortSql = "";
for (int s1 = 0; s1 < listSortName.size(); s1++) {
System.out.println("Sort: " + listSortDisable.get(s1));
if (s1 == listSortName.size() - 1) {
String orderby = " desc ";
if (listSortDisable.get(s1).equals("0"))
orderby = " asc ";
if (listSortName.get(s1).equals("indicationDateTime"))
sortSql = sortSql + " animalReproductionIndication." + listSortName.get(s1) + " " + orderby;
else if (listSortName.get(s1).equals("farmersAnimalNr"))
sortSql = sortSql + " cast(OVALERTAPP." + listSortName.get(s1) + " as integer) " + orderby;
else
sortSql = sortSql + " OVALERTAPP." + listSortName.get(s1) + " " + orderby;
} else {
String orderby = " desc ,";
if (listSortDisable.get(s1).equals("0"))
orderby = " asc ,";
if (listSortName.get(s1).equals("indicationDateTime"))
sortSql = sortSql + " animalReproductionIndication." + listSortName.get(s1) + " " + orderby;
else if (listSortName.get(s1).equals("farmersAnimalNr"))
sortSql = sortSql + " cast(OVALERTAPP." + listSortName.get(s1) + " as integer) " + orderby;
else
sortSql = sortSql + " OVALERTAPP." + listSortName.get(s1) + " " + orderby;
}
}
String sxc = sortSql;
sxc = sxc.trim();
if (!sxc.equals(""))
sortSql = " order by " + sortSql;
System.out.println("Sort: " + sortSql);
try {
sql = " FROM OVALERTAPP, animalReproductionIndication WHERE " + sql_user_hit + " OVALERTAPP.AnimalNumber= animalReproductionIndication.AnimalNumber and " + auswahl + "1 " + sortSql;
String prio = db.getSelect("select nameCode from primaeridentifikation where user='" + userdb + "' and art='1' and disable='1' ");
List<String> einstellung_name = db.getAll("SELECT name from einstellungen where user ='" + userdb + "' and seite='1' and disable='1' ");
List<String> einstellung_nameCode = db.getAll("SELECT nameCode from einstellungen where user ='" + userdb + "' and seite='1' and disable='1' ");
String xxInhalt = " ";
for (int xx = 0; xx < einstellung_name.size(); xx++) {
String namexx = einstellung_name.get(xx);
for (int yy = 0; yy < namexx_.length; yy++) {
namexx = namexx.replace(namexx_[yy], Abkxx_[yy]);
}
xxInhalt = xxInhalt + "' " + namexx + ": ' || OVALERTAPP." + einstellung_nameCode.get(xx) + " ||";
}
xxInhalt = " || '<br>' || " + xxInhalt + " ''";
xxInhalt = xxInhalt.replace("OVALERTAPP.participantAnimal", "OVALERTAPP.participantAnimalNr");
if (einstellung_name.size() < 1) {
xxInhalt = " ";
}
tier_id = db.getAll("SELECT OVALERTAPP.id " + sql);
hin_id = db.getAll("SELECT animalReproductionIndication.id " + sql);
hin_besamt = db.getAll("SELECT animalReproductionIndication.indicationCertainty " + sql);
hin_blaue = db.getAll("select animalReproductionIndication.showType " + sql);
hin_time = db.getAll("select animalReproductionIndication.indicationDateTime " + sql); //gesehen
if (prio.equals("")) {
String sql_ = " SELECT OVALERTAPP.AnimalNumber || ' I.H: ' || '--' || ' T I.B: ' || OVALERTAPP.lastInseminationDate || ' T LT: ' || OVALERTAPP.calvingDate || ' T '|| reproductionStatus " + xxInhalt + " " + sql; // time
sql_ = sql_.replace("OVALERTAPP.aktivseit", "animalReproductionIndication.indicationDateTime");
hin_info = db.getAll(sql_);
// hin_info = db.getAll(" SELECT OVALERTAPP.AnimalNumber || ' I.H: ' || '--' || ' T I.B: ' || OVALERTAPP.lastInseminationDate || ' T LT: ' || OVALERTAPP.calvingDate || ' T '|| reproductionStatus " + xxInhalt + " " + sql); // time
System.out.println(" SELECT OVALERTAPP.AnimalNumber || ' I.H: ' || '--' || ' T I.B: ' || OVALERTAPP.lastInseminationDate || ' T LT: ' || OVALERTAPP.calvingDate || ' T '|| reproductionStatus " + xxInhalt + " " + sql); // time
} else {
//hin_info = db.getAll(" SELECT OVALERTAPP." + prio + " || ' I.H: ' || '--' || ' T I.B: ' || OVALERTAPP.lastInseminationDate || ' T LT: ' || OVALERTAPP.calvingDate || ' T '|| reproductionStatus " + xxInhalt + " " + sql); // time
String sql_ = " SELECT OVALERTAPP." + prio + " || ' I.H: ' || '--' || ' T I.B: ' || OVALERTAPP.lastInseminationDate || ' T LT: ' || OVALERTAPP.calvingDate || ' T '|| reproductionStatus " + xxInhalt + " " + sql; // time
sql_ = sql_.replace("OVALERTAPP.aktivseit", "animalReproductionIndication.indicationDateTime");
hin_info = db.getAll(sql_);
System.out.println(" SELECT OVALERTAPP." + prio + " || ' I.H: ' || '--' || ' T I.B: ' || OVALERTAPP.lastInseminationDate || ' T LT: ' || OVALERTAPP.calvingDate || ' T '|| reproductionStatus " + xxInhalt + " " + sql); // time
}
for (int i = 0; i < hin_besamt.size(); i++) {
String timehin = db.getSelect("SELECT indicationDateTime FROM animalReproductionIndication where animalReproductionIndication.id=" + hin_id.get(i));
String animalhin = db.getSelect("SELECT animalNumber FROM animalReproductionIndication where animalReproductionIndication.id=" + hin_id.get(i));
// List<String> maxList=db.getAll("SELECT indicationDateTime FROM animalReproductionIndication where user='"+userdb+"' and animalNumber='"+animalhin+"' and indicationDateTime!='"+timehin+"' and indicationExpirationDateTime !='' order by indicationDateTime desc ");
String timehin_date = timehin + " ";
List<String> maxList = db.getAll("SELECT indicationDateTimeHin FROM animalReproductionIndicationHinweise where userHin='" + userdb + "' and animalNumberHin='" + animalhin + "' and indicationDateTimeHin!='" + timehin + "' and (indicationDateTimeHin not LIKE '" + timehin_date.substring(0, 8) + "%') and indicationDateTimeHin < '" + timehin + "' order by indicationDateTimeHin desc ");
String hin = "";
if (maxList.size() > 0) {
hin = maxList.get(0);
System.out.println("hin++++" + hin + " neue: " + timehin);
}
//hin=tm.getDayToDay(hin,"yyyyMMddkkmmss");
hin = tm.getDayMinusDayDate(hin, timehin);
String line = statusUmbenennen(hin_info.get(i));
System.out.println("line: " + line);
String info_ = statusUmbenennen(hin_info.get(i));
System.out.println("line1: " + line);
info_ = info_.replace("--", hin);
System.out.println("line2: " + info_);
System.out.println(info_);
String[] anfang = {"I Kalb: ", "I Bes: ", "n Kalb: ", "I Bru: ", " Trocken: "};
String[] end = {"", "", "", "", ""};
String[] anfang1 = {"I.H: ", "I.B: ", "LT: "};
String[] end1 = {"", "", ""};
try {
info_ = lineYMDTag(info_, anfang1, end1);
System.out.println("line3: " + info_);
} catch (ParseException e) {
e.printStackTrace();
}
String[] anfangx = {"Aktiv seit: "};
String[] endx = {""};
try {
info_ = lineYMDHMS(info_, anfangx, endx);
} catch (ParseException e) {
e.printStackTrace();
}
try {
info_ = lineYMD(info_, anfang, end);
System.out.println("line4: " + info_);
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println("info_: " + info_);
ListHinweise item = new ListHinweise();
item.setHinId(tier_id.get(i));
item.setHinId(hin_id.get(i));
item.setHinBlaue(hin_blaue.get(i));
item.setHinInfo(info_);
item.setHinBesamt(hin_besamt.get(i));
System.out.println(hin_time.get(i) + "_xmmx_" + tt.getHourDiffStartToNow(hin_time.get(i), "yyyyMMddkkmmss"));
item.setHinTime(String.valueOf(tt.getHourDiffStartToNow(hin_time.get(i), "yyyyMMddkkmmss")));
list_hinweise.add(item);
db.close();
}
} catch (SQLiteException e) {
e.printStackTrace();
}
return list_hinweise;
}
I have already tried to update the list with onResume or setUserVisibleHint but without success. My refreshContent() method works fine, but I want to update the list automatically and not manually. If I took the onResume() method the Items will be refreshed but then my Tab1 contains the values from Tab1 and Tab2.

I want to fetch the values from AdvancedCriteria

I want to fetch the values from AdvancedCriteria
My Code is like this
Now how can I retrieve values from objects ?
How did you get the values from criteria?
AdvancedCriteria cr = filterBuilder.getCriteria();
JavaScriptObject jso = cr.getJsObj();
Map map = cr.getValues();
Set keys = map.keySet();
Iterator it = keys.iterator();
while( it.hasNext()){
String key = it.next().toString();
system.out.println("=> "+map.get(key));
}
Out put
=> AdvancedCriteria
=> and
=> [object Object]
To print advanced criteria with inner criterias and advanced criterias you can do something like this:
public void onClick(ClickEvent event) {
AdvancedCriteria crit = filterBuilder.getCriteria();
printCriteria(crit, 0);
}
public void printCriteria(AdvancedCriteria ac, int level) {
char[] indentArray = new char[level];
Arrays.fill(indentArray, '\t');
String indent = new String(indentArray);
OperatorId operator = ac.getOperator();
Criteria[] c = ac.getCriteria();
for (int i = 0; i < c.length; i++) {
if (c[i].isAdvanced()) {
System.out.println(indent + "(");
printCriteria(c[i].asAdvancedCriteria(), level + 1);
System.out.println(indent + ")");
} else {
System.out.println(indent +
c[i].getAttributeAsString("fieldName") + " " +
c[i].getAttributeAsString("operator") + " " +
c[i].getAttributeAsString("value"));
}
if ((i + 1) < c.length) {
System.out.println(indent + operator);
}
}

How do you append text in CodeMirror

I know you use
editor.setValue("");
to set one value but how do you append in CodeMirror?
IE:
editor.appendText();?
Use replaceRange. For example editor.replaceRange(myString, CodeMirror.Pos(editor.lastLine())). Re-setting the entire editor is needlessly expensive.
Here is a little script I wrote to add code to any editor (in Joomla):
function addCodeToEditor(code_string, editor_id, merge, merge_target){
if (Joomla.editors.instances.hasOwnProperty(editor_id)) {
var old_code_string = Joomla.editors.instances[editor_id].getValue();
if (merge && old_code_string.length > 0) {
// make sure not to load the same string twice
if (old_code_string.indexOf(code_string) == -1) {
if ('prepend' === merge_target) {
var _string = code_string + "\n\n" + old_code_string;
} else if (merge_target && 'append' !== merge_target) {
var old_code_array = old_code_string.split(merge_target);
if (old_code_array.length > 1) {
var _string = old_code_array.shift() + "\n\n" + code_string + "\n\n" + merge_target + old_code_array.join(merge_target);
} else {
var _string = code_string + "\n\n" + merge_target + old_code_array.join('');
}
} else {
var _string = old_code_string + "\n\n" + code_string;
}
Joomla.editors.instances[editor_id].setValue(_string.trim());
return true;
}
} else {
Joomla.editors.instances[editor_id].setValue(code_string.trim());
return true;
}
} else {
var old_code_string = jQuery('textarea#'+editor_id).val();
if (merge && old_code_string.length > 0) {
// make sure not to load the same string twice
if (old_code_string.indexOf(code_string) == -1) {
if ('prepend' === merge_target) {
var _string = code_string + "\n\n" + old_code_string;
} else if (merge_target && 'append' !== merge_target) {
var old_code_array = old_code_string.split(merge_target);
if (old_code_array.length > 1) {
var _string = old_code_array.shift() + "\n\n" + code_string + "\n\n" + merge_target + old_code_array.join(merge_target);
} else {
var _string = code_string + "\n\n" + merge_target + old_code_array.join('');
}
} else {
var _string = old_code_string + "\n\n" + code_string;
}
jQuery('textarea#'+editor_id).val(_string.trim());
return true;
}
} else {
jQuery('textarea#'+editor_id).val(code_string.trim());
return true;
}
}
return false;
}
The advantage it this script is you can work with multiple editors on the page.