Browse Source

update

old
Yiğit Çolakoğlu 6 years ago
parent
commit
ccc4203592
16 changed files with 282 additions and 1 deletions
  1. +5
    -0
      MyCity/app/build.gradle
  2. +6
    -1
      MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java
  3. +159
    -0
      MyCity/app/src/main/java/gq/yigit/mycity/utilityFragment/UtilityFragment.java
  4. +0
    -0
      MyCity/app/src/main/res/drawable-v24/app_icon.xml
  5. +0
    -0
      MyCity/app/src/main/res/drawable-v24/bus.xml
  6. +0
    -0
      MyCity/app/src/main/res/drawable-v24/magnifier.xml
  7. +0
    -0
      MyCity/app/src/main/res/drawable-v24/navigation.xml
  8. +0
    -0
      MyCity/app/src/main/res/drawable-v24/parking.xml
  9. +0
    -0
      MyCity/app/src/main/res/drawable-v24/side_nav_bar.xml
  10. +0
    -0
      MyCity/app/src/main/res/drawable-v24/star.xml
  11. +0
    -0
      MyCity/app/src/main/res/drawable-v24/subway.xml
  12. +0
    -0
      MyCity/app/src/main/res/drawable-v24/user_icon_def.xml
  13. +0
    -0
      MyCity/app/src/main/res/drawable-v24/utility.xml
  14. +0
    -0
      MyCity/app/src/main/res/drawable-v24/vote.xml
  15. +0
    -0
      MyCity/app/src/main/res/drawable-v24/vote_style.xml
  16. +112
    -0
      MyCity/app/src/main/res/layout/fragment_utility.xml

+ 5
- 0
MyCity/app/build.gradle View File

@ -21,6 +21,11 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
api 'cz.msebera.android:httpclient:4.4.1.2'
implementation 'com.jjoe64:graphview:4.2.2'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:design:27.0.0'


+ 6
- 1
MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java View File

@ -27,6 +27,7 @@ import android.widget.Toast;
import gq.yigit.mycity.navigation.MapsFragment;
import gq.yigit.mycity.tools.*;
import gq.yigit.mycity.tools.WebRequest.responseListener;
import gq.yigit.mycity.utilityFragment.UtilityFragment;
import gq.yigit.mycity.votesFragment.VoteFragment;
import gq.yigit.mycity.votesFragment.VotesContent;
import gq.yigit.mycity.votesFragment.VotesFragment;
@ -46,6 +47,7 @@ public class MainActivity extends AppCompatActivity
MainFragment.OnFragmentInteractionListener,
RateFragment.OnFragmentInteractionListener,
MapsFragment.OnFragmentInteractionListener,
UtilityFragment.OnFragmentInteractionListener,
OnFragmentInteractionListener,
responseListener,
imageListener {
@ -183,7 +185,10 @@ public class MainActivity extends AppCompatActivity
fragmentTransaction.commit();
fragmentTransaction.addToBackStack(null);
} else if (id == R.id.utilities) {
UtilityFragment fragment = new UtilityFragment();
fragmentTransaction.replace(R.id.app_bar_main, fragment);
fragmentTransaction.commit();
fragmentTransaction.addToBackStack(null);
}


+ 159
- 0
MyCity/app/src/main/java/gq/yigit/mycity/utilityFragment/UtilityFragment.java View File

@ -0,0 +1,159 @@
package gq.yigit.mycity.utilityFragment;
import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.helper.StaticLabelsFormatter;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;
import gq.yigit.mycity.R;
import java.util.ArrayList;
import java.util.List;
public class UtilityFragment extends Fragment {
private OnFragmentInteractionListener mListener;
public UtilityFragment() {
}
public static UtilityFragment newInstance(String param1, String param2) {
UtilityFragment fragment = new UtilityFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_utility, container, false);
GraphView graph = (GraphView) rootView.findViewById(R.id.utility_graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint[] {
new DataPoint(0, 1),
new DataPoint(1, 5),
new DataPoint(2, 3)
});
LineGraphSeries<DataPoint> series2 = new LineGraphSeries<>(new DataPoint[] {
new DataPoint(0, 4),
new DataPoint(1, 1),
new DataPoint(2, 7)
});
StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);
staticLabelsFormatter.setHorizontalLabels(new String[] {"old", "middle", "new"});
staticLabelsFormatter.setVerticalLabels(new String[] {"low", "middle", "high"});
graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
series.setTitle("ideal");
series.setColor(Color.BLUE);
series2.setTitle("usage");
series2.setColor(Color.RED);
graph.addSeries(series);
graph.addSeries(series2);
ViewPager viewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
setupViewPager(viewPager);
TabLayout tabs = (TabLayout) rootView.findViewById(R.id.result_tabs);
tabs.setupWithViewPager(viewPager);
return rootView;
}
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
private void setupViewPager(ViewPager viewPager) {
Adapter adapter = new Adapter(getChildFragmentManager());
adapter.addFragment(new UtilityFragment(), "Electricity");
viewPager.setAdapter(adapter);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
class Adapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public Adapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}

MyCity/app/src/main/res/drawable/app_icon.xml → MyCity/app/src/main/res/drawable-v24/app_icon.xml View File


MyCity/app/src/main/res/drawable-v21/bus.xml → MyCity/app/src/main/res/drawable-v24/bus.xml View File


MyCity/app/src/main/res/drawable/magnifier.xml → MyCity/app/src/main/res/drawable-v24/magnifier.xml View File


MyCity/app/src/main/res/drawable-v21/navigation.xml → MyCity/app/src/main/res/drawable-v24/navigation.xml View File


MyCity/app/src/main/res/drawable-v21/parking.xml → MyCity/app/src/main/res/drawable-v24/parking.xml View File


MyCity/app/src/main/res/drawable/side_nav_bar.xml → MyCity/app/src/main/res/drawable-v24/side_nav_bar.xml View File


MyCity/app/src/main/res/drawable-v21/star.xml → MyCity/app/src/main/res/drawable-v24/star.xml View File


MyCity/app/src/main/res/drawable-v21/subway.xml → MyCity/app/src/main/res/drawable-v24/subway.xml View File


MyCity/app/src/main/res/drawable/user_icon_def.xml → MyCity/app/src/main/res/drawable-v24/user_icon_def.xml View File


MyCity/app/src/main/res/drawable-v21/utility.xml → MyCity/app/src/main/res/drawable-v24/utility.xml View File


MyCity/app/src/main/res/drawable-v21/vote.xml → MyCity/app/src/main/res/drawable-v24/vote.xml View File


MyCity/app/src/main/res/drawable/vote_style.xml → MyCity/app/src/main/res/drawable-v24/vote_style.xml View File


+ 112
- 0
MyCity/app/src/main/res/layout/fragment_utility.xml View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".utilityFragment.UtilityFragment" android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.TabLayout
android:id="@+id/result_tabs"
android:background="#e8e8e8"
app:tabTextColor="#d5d5d5"
app:tabSelectedTextColor="@color/colorPrimary"
app:tabIndicatorColor="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<com.jjoe64.graphview.GraphView
android:layout_width="match_parent"
android:layout_height="254dp"
android:id="@+id/utility_graph"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:text="Your Points:"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView"
android:textColor="@android:color/holo_orange_dark" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="Your Bill:"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView1"
android:textColor="@android:color/holo_orange_dark" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="%Efficieny:"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView2"
android:textColor="@android:color/holo_orange_dark" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Content Here"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/points_utility"
android:textColor="@android:color/black" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="Content Here"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/bill_utility"
android:textColor="@android:color/black" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
<TextView
android:text="Content Here"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/efficieny_utility"
android:textColor="@android:color/black" android:textSize="16sp"
android:layout_marginVertical="4dp" android:layout_marginHorizontal="7dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/button" android:layout_weight="1"/>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/button2" android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>

Loading…
Cancel
Save