-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from tobykurien/master
Added a ViewPager to allow swiping of detail views for #116
- Loading branch information
Showing
8 changed files
with
161 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/SecUpwN/AIMSICD/adapters/DetailsPagerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.SecUpwN.AIMSICD.adapters; | ||
|
||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentManager; | ||
import android.support.v4.app.FragmentPagerAdapter; | ||
|
||
import com.SecUpwN.AIMSICD.fragments.CellInfoFragment; | ||
import com.SecUpwN.AIMSICD.fragments.DbViewerFragment; | ||
import com.SecUpwN.AIMSICD.fragments.DeviceFragment; | ||
|
||
/** | ||
* Adapter to allow swiping between various detail fragments | ||
*/ | ||
public class DetailsPagerAdapter extends FragmentPagerAdapter { | ||
|
||
public DetailsPagerAdapter(FragmentManager fm) { | ||
super(fm); | ||
} | ||
|
||
@Override | ||
public Fragment getItem(int position) { | ||
switch (position) { | ||
case 0: return new DeviceFragment(); | ||
case 1: return new CellInfoFragment(); | ||
case 2: return new DbViewerFragment(); | ||
} | ||
|
||
return new DeviceFragment(); | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
// map position to position in AIMSICD.getNavDrawerConfiguration | ||
switch (position) { | ||
case 0: return 4; | ||
case 1: return 5; | ||
case 2: return 7; | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return 3; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
app/src/main/java/com/SecUpwN/AIMSICD/fragments/DetailsContainerFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.SecUpwN.AIMSICD.fragments; | ||
|
||
|
||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.view.ViewPager; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import com.SecUpwN.AIMSICD.AIMSICD; | ||
import com.SecUpwN.AIMSICD.R; | ||
import com.SecUpwN.AIMSICD.adapters.DetailsPagerAdapter; | ||
import com.SecUpwN.AIMSICD.drawer.DrawerMenuActivityConfiguration; | ||
import com.SecUpwN.AIMSICD.drawer.NavDrawerItem; | ||
|
||
/** | ||
* This fragment will host child fragments to display device details, cell info, etc. | ||
*/ | ||
public class DetailsContainerFragment extends Fragment { | ||
ViewPager vp; | ||
DetailsPagerAdapter adapter; | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
return inflater.inflate(R.layout.fragment_details_container, container, false); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
|
||
final DrawerMenuActivityConfiguration mNavConf = ((AIMSICD) getActivity()).getNavDrawerConfiguration(); | ||
adapter = new DetailsPagerAdapter(getChildFragmentManager()); | ||
|
||
vp = (ViewPager) view.findViewById(R.id.details_pager); | ||
vp.setAdapter(adapter); | ||
vp.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { | ||
@Override | ||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { | ||
|
||
} | ||
|
||
@Override | ||
public void onPageSelected(int position) { | ||
int navId = (int) adapter.getItemId(position); | ||
NavDrawerItem selectedItem = mNavConf.getNavItems().get(navId); | ||
getActivity().getActionBar().setTitle(selectedItem.getLabel()); | ||
} | ||
|
||
@Override | ||
public void onPageScrollStateChanged(int state) { | ||
|
||
} | ||
}); | ||
} | ||
|
||
public void setCurrentPage(int page) { | ||
if (page >= 0 && page < adapter.getCount()) { | ||
vp.setCurrentItem(page); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<FrameLayout | ||
android:id="@+id/details_fragment_container" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<android.support.v4.view.ViewPager | ||
android:id="@+id/details_pager" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> | ||
|
||
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'csv' | ||
|
||
CSV.foreach('cell_towers.csv') do |row| | ||
# radio,mcc,net,area,cell,unit,lon,lat,range,samples,changeable,created,updated,averageSignal | ||
File.open("data/#{row[1]}.csv", 'a') do |json_writer| | ||
json_writer.write "#{row[4]},#{row[6]},#{row[7]}\n" | ||
end | ||
end | ||
|