trying some wild stuff
This commit is contained in:
		
							parent
							
								
									df6d80f729
								
							
						
					
					
						commit
						ed6927b7db
					
				
					 7 changed files with 137 additions and 27 deletions
				
			
		
							
								
								
									
										14
									
								
								OlympusServices/.idea/assetWizardSettings.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								OlympusServices/.idea/assetWizardSettings.xml
									
										
									
										generated
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project version="4">
 | 
			
		||||
  <component name="WizardSettings">
 | 
			
		||||
    <option name="children">
 | 
			
		||||
      <map>
 | 
			
		||||
        <entry key="vectorWizard">
 | 
			
		||||
          <value>
 | 
			
		||||
            <PersistentState />
 | 
			
		||||
          </value>
 | 
			
		||||
        </entry>
 | 
			
		||||
      </map>
 | 
			
		||||
    </option>
 | 
			
		||||
  </component>
 | 
			
		||||
</project>
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								OlympusServices/.idea/caches/build_file_checksums.ser
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								OlympusServices/.idea/caches/build_file_checksums.ser
									
										
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -35,6 +35,7 @@ dependencies {
 | 
			
		|||
    implementation 'com.jaredrummler:material-spinner:1.2.5'
 | 
			
		||||
    implementation 'com.android.support:design:28.0.0-alpha3'
 | 
			
		||||
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
 | 
			
		||||
    implementation 'com.android.support:recyclerview-v7:28.0.0'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
repositories {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,70 @@
 | 
			
		|||
package com.uottawa.olympus.olympusservices;
 | 
			
		||||
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.support.annotation.NonNull;
 | 
			
		||||
import android.support.v7.widget.RecyclerView;
 | 
			
		||||
import android.view.LayoutInflater;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.TextView;
 | 
			
		||||
 | 
			
		||||
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ServicesHolder> {
 | 
			
		||||
 | 
			
		||||
    private Service[] services;
 | 
			
		||||
 | 
			
		||||
    // Provide a reference to the views for each data item
 | 
			
		||||
    // Complex data items may need more than one view per item, and
 | 
			
		||||
    // you provide access to all the views for a data item in a view holder
 | 
			
		||||
 | 
			
		||||
    // Provide a suitable constructor (depends on the kind of dataset)
 | 
			
		||||
    public MyAdapter(Service[] services) {
 | 
			
		||||
        this.services = services;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Create new views (invoked by the layout manager)
 | 
			
		||||
    @NonNull
 | 
			
		||||
    @Override
 | 
			
		||||
    public ServicesHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
 | 
			
		||||
        View v = LayoutInflater.from(parent.getContext())
 | 
			
		||||
                .inflate(R.layout.list_item, parent, false);
 | 
			
		||||
        ServicesHolder vh = new ServicesHolder(v);
 | 
			
		||||
        return vh;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Replace the contents of a view (invoked by the layout manager)
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onBindViewHolder(ServicesHolder holder, int position) {
 | 
			
		||||
        Service service = services[position];
 | 
			
		||||
        holder.name.setText(service.getName());
 | 
			
		||||
        holder.rate.setText(""+service.getRate());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Return the size of your dataset (invoked by the layout manager)
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getItemCount() {
 | 
			
		||||
        return services.length;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    class ServicesHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
 | 
			
		||||
 | 
			
		||||
        TextView name;
 | 
			
		||||
        TextView rate;
 | 
			
		||||
 | 
			
		||||
        public ServicesHolder(View row){
 | 
			
		||||
            super(row);
 | 
			
		||||
            name = row.findViewById(R.id.Name);
 | 
			
		||||
            rate = row.findViewById(R.id.Rate);
 | 
			
		||||
            row.setOnClickListener(this);
 | 
			
		||||
        }
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onClick(View view) {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -3,6 +3,8 @@ package com.uottawa.olympus.olympusservices;
 | 
			
		|||
import android.support.v4.app.DialogFragment;
 | 
			
		||||
import android.support.v7.app.AppCompatActivity;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.support.v7.widget.LinearLayoutManager;
 | 
			
		||||
import android.support.v7.widget.RecyclerView;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.widget.AdapterView;
 | 
			
		||||
import android.widget.ArrayAdapter;
 | 
			
		||||
| 
						 | 
				
			
			@ -14,31 +16,34 @@ import java.util.List;
 | 
			
		|||
 | 
			
		||||
public class ServicesList extends AppCompatActivity implements NewServiceDialogFragment.NoticeDialogListener, EditServiceDialogFragment.NoticeDialogListener{
 | 
			
		||||
 | 
			
		||||
    private RecyclerView mRecyclerView;
 | 
			
		||||
    private RecyclerView.Adapter mAdapter;
 | 
			
		||||
    private RecyclerView.LayoutManager mLayoutManager;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
        super.onCreate(savedInstanceState);
 | 
			
		||||
        setContentView(R.layout.activity_services_list);
 | 
			
		||||
        DBHelper dbHelper = new DBHelper(this);
 | 
			
		||||
        List<String[]> users = dbHelper.getAllServices();
 | 
			
		||||
        String[] services = new String[(users.size()+1)*2];
 | 
			
		||||
        services[0] = "Name";
 | 
			
		||||
        services[1] = "Rate";
 | 
			
		||||
        Iterator iter = users.iterator();
 | 
			
		||||
        for (int i=0; i<users.size();i++){
 | 
			
		||||
        List<String[]> serviceslist = dbHelper.getAllServices();
 | 
			
		||||
        Service[] services = new Service[(serviceslist.size())];
 | 
			
		||||
        Iterator iter = serviceslist.iterator();
 | 
			
		||||
        for (int i=0; i<serviceslist.size();i++){
 | 
			
		||||
            String[] current = (String[])iter.next();
 | 
			
		||||
            services[(i+1)*2] = current[0];
 | 
			
		||||
            services[(i+1)*2+1] = current[1];
 | 
			
		||||
            services[i] = new Service(current[0], Double.parseDouble(current[1]));
 | 
			
		||||
        }
 | 
			
		||||
        ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.simple_list_item_1_customized, services);
 | 
			
		||||
        GridView gridView = findViewById(R.id.Services);
 | 
			
		||||
        gridView.setAdapter(adapter);
 | 
			
		||||
        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onItemClick(AdapterView<?> parent, View view,
 | 
			
		||||
                                    int position, long id) {
 | 
			
		||||
                editService(view);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
        mRecyclerView = (RecyclerView) findViewById(R.id.Services);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        mLayoutManager = new LinearLayoutManager(this);
 | 
			
		||||
        mRecyclerView.setLayoutManager(mLayoutManager);
 | 
			
		||||
 | 
			
		||||
        mAdapter = new MyAdapter(services);
 | 
			
		||||
        mRecyclerView.setAdapter(mAdapter);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    public void addService(View view) {
 | 
			
		||||
        DialogFragment newFragment = new NewServiceDialogFragment();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,17 +26,13 @@
 | 
			
		|||
        app:fontFamily="@font/julius_sans_one" />
 | 
			
		||||
    <LinearLayout
 | 
			
		||||
        android:layout_width="match_parent"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:orientation="horizontal">
 | 
			
		||||
        android:layout_height="wrap_content">
 | 
			
		||||
 | 
			
		||||
        <GridView
 | 
			
		||||
        <android.support.v7.widget.RecyclerView
 | 
			
		||||
            android:id="@+id/Services"
 | 
			
		||||
            android:layout_width="fill_parent"
 | 
			
		||||
            android:layout_weight="1"
 | 
			
		||||
            android:layout_height="250dp"
 | 
			
		||||
            android:numColumns="2"
 | 
			
		||||
            android:textColor="@android:color/white"
 | 
			
		||||
            android:textSize="15sp" />
 | 
			
		||||
            android:scrollbars="vertical"
 | 
			
		||||
            android:layout_width="match_parent"
 | 
			
		||||
            android:layout_height="match_parent"/>
 | 
			
		||||
 | 
			
		||||
    </LinearLayout>
 | 
			
		||||
    <Button
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										24
									
								
								OlympusServices/app/src/main/res/layout/list_item.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								OlympusServices/app/src/main/res/layout/list_item.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
    android:layout_width="match_parent"
 | 
			
		||||
    android:layout_height="match_parent">
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
        android:id="@+id/Name"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_weight="1"
 | 
			
		||||
        android:text=""
 | 
			
		||||
        android:textColor="@color/colorWhite"
 | 
			
		||||
        android:textSize="15sp"/>
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
        android:id="@+id/Rate"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_weight="1"
 | 
			
		||||
        android:text=""
 | 
			
		||||
        android:textColor="@color/colorWhite"
 | 
			
		||||
        android:textSize="15sp"/>
 | 
			
		||||
</LinearLayout>
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue